DataGrid中添加个复选框
决定做一个可重用的控制,将增加一个复选框DataGrid 。
然后添加复选框列到DataGrid :
该CheckBoxColumn类相当简单:
2个属性:
SelectedDataKeys:返回一个ArrayList使用DataKey值
SelectedIndexes:Returns anInt32 []with theselectedIndexvaluesSelectedIndexes:返回一个Int32 []与selectedIndex值要找出复选框被选中:
这几乎是它的
DataKeyField的DataGrid可以是任何类型。 The sample I've included binds aDataTableto theDataGrid, you can change theDataKeyFieldfrom "ID" (int) to "Name" (string) to see the code working with different types.所包含的示例中,我已经绑定了一个DataTable到DataGrid,你可以改变DataKeyField由“ID“(int),以“Name“(string)来查看代码类型使用不同的。
本文介绍如何在DataGrid中添加复选框列,并提供了一个可重用的CheckBoxColumn类,该类允许用户选择多行并获取所选行的索引及数据键。
4012

被折叠的 条评论
为什么被折叠?



