【发布时间】:2009-04-24 06:11:32
【问题描述】:
如何在 Infragistics UltraGrid 中动态添加复选框
【问题讨论】:
标签: ultrawingrid
如何在 Infragistics UltraGrid 中动态添加复选框
【问题讨论】:
标签: ultrawingrid
只需确保您要绑定的列的数据类型为 bool 类型。它会自动为该列创建复选框。
【讨论】:
试试下面的
//get the data from db
var ds = GetDataFromDatabase();
ds.Tables[0].Columns.Add("Check", typeof(bool)); //this will create checkbox col
foreach(Datarow row in ds.Tables[0].Rows)
{
row["Check"] = true; // make all rows checked just to see it works
}
DataView dv = ds.Tables[0].DefaultView; //set it as a dataview
ultraGrid1.DataSource = dv; //set the dataview as the datasource for your grid
【讨论】:
确保列数据类型为bool(真/假或0/1)然后设置:
grid.DisplayLayout.Bands[0].Columns["column_name"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
应该可以的。
【讨论】:
在将数据绑定到网格时,可以通过下面的查询调用数据表的集合:
“选择 Convert(bit,0) as IsChecked, [OTHER_COLUMNS] from [TABLE_NAME]”
这将返回一个带有第一列复选框的数据表。
使用数据源将其与您的网格绑定。
【讨论】: