在datagridview中添加复选框 [英] Adding checkbox in datagridview

查看:83
本文介绍了在datagridview中添加复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在datagridview中添加复选框. datagridview(properties)->列->在这里,我选择DataGridViewCheckBoxColumn

bt当我运行项目时,我无法选中该复选框.
项目给出任何错误,所以我不知道该怎么办?

I want to add checkbox in datagridview.. i tried it from
datagridview(properties)-> Columns -> Here i select DataGridViewCheckBoxColumn

bt when i run the project, i cant checked the checkbox.
project giving any error so i dont know wht to do??

推荐答案

您可能已禁用DataGridView的编辑.
http://social.msdn.microsoft.com /forums/zh-CN/winforms/thread/65d49d7c-9efb-49a6-9a24-41b718ab5700/ [
You may have the editing of DataGridView disabled.
http://social.msdn.microsoft.com/forums/en-US/winforms/thread/65d49d7c-9efb-49a6-9a24-41b718ab5700/[^]


亲爱的Sumit,

有时此datagridview显示异常行为,因此从我这一点来看,解决方案可能是:-

1)检查该字段是否不是只读的.
2)尝试卸载应用程序并重建它,然后重新运行它.
3)尝试添加具有相同配置的新网格.(但这必须是最后一个选项)

希望这对您有所帮助.

感谢
Dear Sumit,

Sometimes this datagridview shows unusual behavior so from my side the solution could be:-

1) check whether the field is not read only.
2) try to unload the application and rebuild it and then re-run it.
3) Try to add new grid with same configuration.(but this must be the last option)

Hope this will help you out.

Thanks


使用模板字段,因为这不是内置类型复选框.
use template field, for this not of inbuilt type check box column.
<asp:GridView ID="grdMain" runat="server" AutoGenerateColumns="False"  OnRowDataBound="grdMain_RowDataBound" OnRowCommand="grdMain_RowCommand">
     <Columns>
        <asp:TemplateField HeaderStyle-Height="25px" ItemStyle-Height="25px">
         <ItemTemplate>
        <asp:CheckBox ID="chkSelect" runat="server" />
     </ItemTemplate>
                           <HeaderStyle CssClass="GreenBorder" HorizontalAlign='left' />

                     </asp:TemplateField>
                      <asp:TemplateField>
                       <HeaderTemplate>
                                      Serial No.
              </HeaderTemplate>
 <ItemTemplate>
       <asp:Label ID="lblSerialNo" runat="server" Text='<%#Eval("Serial_No")%>'></asp:Label>
                            </ItemTemplate>

</asp:TemplateField>
</Columns>
</asp:GridView>


这样使用,希望对您有所帮助.
如果它有帮助,请不要将froget标记为答案. :)


use like this , Hope this will help you.
Don''t froget to mark as answer if it helps. :)


这篇关于在datagridview中添加复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆