欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Devexpress中Gridcontrol查找分组

程序员文章站 2022-09-09 12:52:25
1 private void button1_Click(object sender, EventArgs e) 2 { 3 DataTable dt = new DataTable(); 4 dt.Columns.Add("Group"); 5 dt.Columns.Add("id... ......

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查找分组

总结

以上所述是小编给的大家介绍的devexpress中gridcontrol查找分组 ,希望对大家有所帮助