vs2003 ,winform 下一个column绑定一个checkbox是很容易的,直接用DataGridBoolColumn设置就可以啦。
但是一个column如何绑定多个checkbox呢,我查了很多资料,都没找到解决方案,自己乱写了些代码,还是不行,有这方面经验的,请赐教!
我要实现的效果是这样的
---------------------------------------------------------------------------
| 第一列标题 | 第二列标题 |
| value1 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value2 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value3 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value4 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value5 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value6 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value7 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
--------------------------------------------------------------------------明白我的意思了吧。这种如何实现呢?有没有人做过???????????写的部分代码在http://community.csdn.net/Expert/topic/4770/4770181.xml?temp=.5465357里
但是一个column如何绑定多个checkbox呢,我查了很多资料,都没找到解决方案,自己乱写了些代码,还是不行,有这方面经验的,请赐教!
我要实现的效果是这样的
---------------------------------------------------------------------------
| 第一列标题 | 第二列标题 |
| value1 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value2 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value3 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value4 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value5 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value6 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
| value7 | 第一个checkbox, 第二个checkbox 共显示5个checkbox |
--------------------------------------------------------------------------明白我的意思了吧。这种如何实现呢?有没有人做过???????????写的部分代码在http://community.csdn.net/Expert/topic/4770/4770181.xml?temp=.5465357里
解决方案 »
- 【求助】visual Studio 2010 用法?
- C#方法中值传递的问题?
- 请高手解答一下这段代码是什么意思
- 有参考价值的C#开源代码
- Socket 类中有没有像 TcpListener 类 的 Pending()一样方法,可以检测是否有请求???
- c#中hook全局鼠标跟flash出现慢动作,鼠标会飘移很慢
- 怎样在WinForm+Access程序中使用事务
- 根据字符串截取生成数组
- 求助一段简单算法
- 在线等,求助大佬们,webBrowser获取到登录后的标头值
- 如果dropdownlist里面的值很多,使用什么方便选择比较好一点
- 在制作安装程序的时候我想把当前日期写到注册表中,请问该怎么做?
给你一个例子
// code assumes you have a DataSet named myDataSet, a table named "EastCoastSales" and a DataGrid myDataGrid
//STEP 1: Create a DataTable style object and set properties if required.
DataGridTableStyle ts1 = new DataGridTableStyle();
//specify the table from dataset (required step)
ts1.MappingName = "EastCoastSales";
// Set other properties (optional step)
ts1.AlternatingBackColor = Color.LightBlue;
//STEP 2: Create a string column and add it to the tablestyle
DataGridColumnStyle TextCol = new DataGridTextBoxColumn();
TextCol.MappingName = "custName"; //from dataset table
TextCol.HeaderText = "Customer Name";
TextCol.Width = 250;
ts1.GridColumnStyles.Add(TextCol);
//STEP 3: Create an int column style and add it to the tablestyle
//this requires setting the format for the column through its property descriptor
PropertyDescriptorCollection pdc = this.BindingContext
[myDataSet, "EastCoastSales"].GetItemProperties();
//now created a formated column using the pdc
DataGridDigitsTextBoxColumn csIDInt =
new DataGridDigitsTextBoxColumn(pdc["CustID"], "i", true);
csIDInt.MappingName = "CustID";
csIDInt.HeaderText = "CustID";
csIDInt.Width = 100;
ts1.GridColumnStyles.Add(csIDInt);
//STEP 4: Add the checkbox
DataGridColumnStyle boolCol = new DataGridBoolColumn();
boolCol.MappingName = "Current";
boolCol.HeaderText = "Info Current";
//uncomment this line to get a two-state checkbox
//((DataGridBoolColumn)boolCol).AllowNull = false;
boolCol.Width = 150;
ts1.GridColumnStyles.Add(boolCol);
//STEP 5: Add the tablestyle to your datagrid's tablestlye collection
myDataGrid.TableStyles.Add(ts1);
<ItemStyle Width="60px" />
<ItemTemplate>
<asp:CheckBox ID="chk1" runat="server"></asp:CheckBox>
<asp:CheckBox ID="chk2" runat="server"></asp:CheckBox>
<asp:CheckBox ID="chk3" runat="server"></asp:CheckBox>
...
</ItemTemplate>
</asp:TemplateField>搞定,在要使用的时候用 (CheckBox)Grid.Rows[行号].FindControl("chk1") 即可找到对象使用了
我要实现一个单元格里,能包括5个checkbox,你的例子里只有一个checkbox。To dafeifei(大飞飞):
我现在要在winform里实现,不是web form
没错,是要继承的。我自己写了一个继承类http://community.csdn.net/Expert/topic/4770/4770181.xml?temp=.5465357
只是只有在编辑状态下才显示出来。
你的方法如何实现呢?