标签:winform str val selected int 选中一行 style tostring control
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()); }
标签:winform str val selected int 选中一行 style tostring control
原文地址:https://www.cnblogs.com/SoftWareIe/p/8757352.html