This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
FormMain.cs
61 lines (55 loc) · 2.19 KB
/
FormMain.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using DevExpress.XtraGrid.Views.Grid;
using System;
using System.Data;
using System.Windows.Forms;
namespace SelfReferenced
{
public partial class FormMain : Form
{
DataSet dataSet11;
public FormMain()
{
InitializeComponent();
}
private void Form1_Load(object sender, System.EventArgs e)
{
dataSet11 = new DataSet();
dataSet11.Tables.Add(GetProductsDataTable());
dataSet11.Relations.Add("ProductsProducts", dataSet11.Tables["Products"].Columns["ID"], dataSet11.Tables["Products"].Columns["ParentID"]);
DataView dv = new DataView(dataSet11.Tables[0]);
dv.RowFilter = "([ParentID] Is NULL)";
gridControl1.DataSource = dv;
gridView1.OptionsDetail.ShowDetailTabs = false;
}
DataTable GetProductsDataTable()
{
DataTable table = new DataTable();
table.TableName = "Products";
table.Columns.Add(new DataColumn("ID", typeof(Int32)));
table.Columns.Add(new DataColumn("ParentID", typeof(Int32)));
table.Columns.Add(new DataColumn("ImageIndex", typeof(int)));
table.Columns.Add(new DataColumn("Department", typeof(string)));
table.Columns.Add(new DataColumn("Budget", typeof(int)));
table.Columns.Add(new DataColumn("Location", typeof(string)));
table.Rows.Add(0, null, 0, "Departament " + 0, 1000, "Location " + 0);
for (int i = 0; i < 20; i++)
{
int index = i + 1;
table.Rows.Add(index, i % 4, i % 5, "Departament " + index, (index % 7) * 1000, "Location " + index);
}
return table;
}
private void gridView1_MasterRowGetLevelDefaultView(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowGetLevelDefaultViewEventArgs e)
{
GridView view = new GridView(gridControl1);
view.Assign(gridControl1.MainView, true);
view.OptionsView.ShowGroupPanel = false;
e.DefaultView = view;
}
[STAThread]
static void Main()
{
Application.Run(new FormMain());
}
}
}