首页 > Windows开发 > 详细

c# winForm换件之SuperGridControl

时间:2018-04-09 10:35:20      阅读:465      评论:0      收藏:0      [点我收藏+]

1.添加表头

            sgc.PrimaryGrid.SelectionGranularity = SelectionGranularity.Row;//点击选中一行
            DevComponents.DotNetBar.SuperGrid.GridColumn gc = null;

            gc = new DevComponents.DotNetBar.SuperGrid.GridColumn("ID");
            sgc.PrimaryGrid.Columns.Add(gc);
            gc = new DevComponents.DotNetBar.SuperGrid.GridColumn("类型编码");
            sgc.PrimaryGrid.Columns.Add(gc);

2.添加数据 加一行

sgc.PrimaryGrid.Rows.Add(new GridRow(new object[] { "a", "b" }));//也就是加一个GrindRow对像 

 

3.设点击选中一行后 取第一行第一列的值

SelectedElementCollection col = sgc.PrimaryGrid.GetSelectedRows();//选中的行集合

if (col.Count > 0)
    {
      GridRow gr = (col[0] as GridRow);//把第一行转为GridRow 
      fac.ID = int.Parse(gr.Cells[0].Value.ToString());//取第一列的Value转一下

      //等效于int id= int.Parse((sgc.PrimaryGrid.GetSelectedRows()[0] as GridRow).Cells[0].Value.ToString());
     }

 

c# winForm换件之SuperGridControl

原文:https://www.cnblogs.com/SoftWareIe/p/8757352.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!