Devexpress中Gridcontrol查找分组
编程学习 2021-07-04 22:41www.dzhlxh.cn编程入门
本文通过实例代码给大家介绍了Devexpress中Gridcontrol查找分组的方法,非常不错,具有一定的参考价诶接价值,需要的朋友一起看看吧
Devexpress中Gridcontrol查找分组 ,具体代码如下所述:
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查找分组 ,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言,长沙网络推广会及时回复大家的!