码迷,mamicode.com
首页 > 其他好文 > 详细

Devexpress中Gridcontrol查找分组

时间:2018-08-04 20:17:04      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:分享   ima   click   nta   tab   field   set   style   res   

 1         private void button1_Click(object sender, EventArgs e)
 2         {
 3             DataTable dt = new DataTable();
 4             dt.Columns.Add("Group");
 5             dt.Columns.Add("idex");
 6             dt.Columns.Add("name");
 7             for (int i = 0; i < 5; i++)
 8             {
 9                 DataRow dr = dt.NewRow();
10                 dr["Group"] = "<5";
11                 dr["idex"] = i.ToString();
12                 dr["name"] = "姓名" + i.ToString();
13                 dt.Rows.Add(dr);
14             }
15             for (int i = 5; i <= 10; i++)
16             {
17                 DataRow dr = dt.NewRow();
18                 dr["Group"] = "(5,10]";
19                 dr["idex"] = i.ToString();
20                 dr["name"] = "姓名" + i.ToString();
21                 dt.Rows.Add(dr);
22             }
23             for (int i = 10; i <= 15; i++)
24             {
25                 DataRow dr = dt.NewRow();
26                 dr["Group"] = "(10,15]";
27                 dr["idex"] = i.ToString();
28                 dr["name"] = "姓名" + i.ToString();
29                 dt.Rows.Add(dr);
30             }
31 
32             gridColumnNumber.FieldName = "idex";
33             gridColumnName.FieldName = "name";
34             gridColumnGroup.FieldName = "Group";
35             gridColumnGroup.GroupIndex = 0;
36             gdc.DataSource = dt;
37             gdv.ExpandAllGroups();
38 
39             for (int i = -1; gdv.IsGroupRow(i); i--)
40             {
41                 DataRow dr = gdv.GetDataRow(gdv.GetDataRowHandleByGroupRowHandle(i));
42                 if (dr == null) return;
43                 if (dr["Group"].ToString() == "(5,10]")
44                 {
45                     gdv.CollapseAllGroups();
46                     gdv.FocusedRowHandle = i;
47                     gdv.SetRowExpanded(i, true);
48                     return;
49                 }
50             }
51         }

技术分享图片

 

Devexpress中Gridcontrol查找分组

标签:分享   ima   click   nta   tab   field   set   style   res   

原文地址:https://www.cnblogs.com/LikeHeart/p/9293724.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!