在 UltraGrid 中添加复选框

发布于 2024-07-17 05:17:31 字数 42 浏览 8 评论 0原文

如何在 infragistics UltraGrid 中动态添加复选框

How to dynamically add checkbox in infragistics UltraGrid

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

落墨 2024-07-24 05:17:31

只需确保要绑定的列的数据类型是 bool 类型即可。 它将自动为该列创建复选框。

Just make sure that the data-type of the column you are binding is of type bool. It will automatically create checkbox for that column.

北斗星光 2024-07-24 05:17:31

尝试以下操作

 //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

try the following

 //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
半仙 2024-07-24 05:17:31

确保列数据类型为 bool(True/False 或 0/1),然后设置:

grid.DisplayLayout.Bands[0].Columns["column_name"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;

应该可以。

Make sure the column data type is bool (True/False or 0/1) then set:

grid.DisplayLayout.Bands[0].Columns["column_name"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;

That should work.

放血 2024-07-24 05:17:31

将数据绑定到网格时,您可以通过以下查询调用数据表的集合:

“Select Convert(bit,0) as IsChecked, [OTHER_COLUMNS] from [TABLE_NAME]”

这将返回带有第一列复选框的数据表。

使用数据源将其与您的网格绑定。

While binding data to the grid, you can call the collection of a datatable through the query below:

"Select Convert(bit,0) as IsChecked, [OTHER_COLUMNS] from [TABLE_NAME]"

This will return a datatable with a first column of checkboxes.

Bind it with your grid using datasource.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文