GetGridViewByFieldManage(ResourceDictionary resources, string moduleName, int groupID)
{
GridView gv = new GridView();
DataTable dt = fieldManageBLL.GetFieldManage(moduleName);
for(int i=0;i<dt.Rows.Count;i++)
{
if(i==0)
{
GridViewColumn gvc=new GridViewColumn();
CheckBox cb = new CheckBox();
cb.Checked += new RoutedEventHandler(cb_Checked);
cb.Unchecked += new RoutedEventHandler(cb_Unchecked);
TextBlock tb = new TextBlock();
tb.Text = "全选";
cb.Content = tb;
_gvc.Header = cb;
_gvc.Width = 100;
_gvc.CellTemplate = (DataTemplate)resources["TheCheckBox"];
gv.Columns.Add(_gvc);
continue;
}
gvc.DisplayMemberBinding = new Binding(dt.Rows[i]["FieldManage_Field"].ToString());
}
return gv;
}
//其中:dt.Rows[i]["FieldMana
WPF中为ListView动态绑定数据且添加一列复选框
最新推荐文章于 2024-08-14 08:40:54 发布
该博客介绍了如何在WPF中使用ListView动态绑定一个包含复选框列的DataTable。通过在已填充的数据表中添加DataColumn实现这一功能。
摘要由CSDN通过智能技术生成