Devexpress中Gridcontrol查找分组 ,具体代码如下所述:
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
|
private void button1_Click( object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add( "Group" );
dt.Columns.Add( "idex" );
dt.Columns.Add( "name" );
for ( int i = 0; i < 5; i++)
{
DataRow dr = dt.NewRow();
dr[ "Group" ] = "<5" ;
dr[ "idex" ] = i.ToString();
dr[ "name" ] = "姓名" + i.ToString();
dt.Rows.Add(dr);
}
for ( int i = 5; i <= 10; i++)
{
DataRow dr = dt.NewRow();
dr[ "Group" ] = "(5,10]" ;
dr[ "idex" ] = i.ToString();
dr[ "name" ] = "姓名" + i.ToString();
dt.Rows.Add(dr);
}
for ( int i = 10; i <= 15; i++)
{
DataRow dr = dt.NewRow();
dr[ "Group" ] = "(10,15]" ;
dr[ "idex" ] = i.ToString();
dr[ "name" ] = "姓名" + i.ToString();
dt.Rows.Add(dr);
}
gridColumnNumber.FieldName = "idex" ;
gridColumnName.FieldName = "name" ;
gridColumnGroup.FieldName = "Group" ;
gridColumnGroup.GroupIndex = 0;
gdc.DataSource = dt;
gdv.ExpandAllGroups();
for ( int i = -1; gdv.IsGroupRow(i); i--)
{
DataRow dr = gdv.GetDataRow(gdv.GetDataRowHandleByGroupRowHandle(i));
if (dr == null ) return ;
if (dr[ "Group" ].ToString() == "(5,10]" )
{
gdv.CollapseAllGroups();
gdv.FocusedRowHandle = i;
gdv.SetRowExpanded(i, true );
return ;
}
}
}
|
总结
以上所述是小编给的大家介绍的Devexpress中Gridcontrol查找分组 ,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,小编会及时回复大家的!
原文链接:https://www.cnblogs.com/LikeHeart/archive/2018/08/04/9293724.html