我如何在DataGrid视图中使用复选框 [英] how can i use the check boxes in datagrid view

查看:66
本文介绍了我如何在DataGrid视图中使用复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

在我使用datagrid视图的Windows应用程序中,我有带有复选框的列,我的要求是,当我选中并单击一个按钮时,应删除完整的行,
请提供一个想法并说明如何执行此操作.

hi to all

in my windows application that i am using the datagrid view in that i had column with check box, my requirement is that when i checked and click a button then that complete row should be delete ,
plz provide an idea and explain how to do this

推荐答案

DataGridView有一个CheckBox列.用那个.在按钮单击事件处理程序中,遍历各行以查找选中的行并删除.

还有很多其他方法可以找到并跟踪已检查的行.
DataGridView has a CheckBox column. Use that. In the button click event handler, loop through the rows to find the checked ones and delete.

There quite a few other ways too to find and keep track of the checked rows.


亲爱的
在按钮上单击事件遍历行,选中该复选框并删除该行(例如grdDetails.Rows.RemoveAt(intRowCount),或者如果您使用的是foreach循环,则使用grdDetails.Rows.Remove(grdRow)).

除此之外,如果有两种方式绑定,如果您从数据源中删除该行,则将自动删除网格中的该行.

希望它能起作用...如果不给我您的电子邮件ID,我将给您发送一个示例. :-O

问候
Manuj Sharma
dear
On button click event traverse row in which checkbox is checked and delete that row ( e.g grdDetails.Rows.RemoveAt(intRowCount) or if you are using foreach loop use grdDetails.Rows.Remove(grdRow)).

Apart from this if there is two way binding if you delete the row from the datasource then automatically that row from grid will be deleted.

Hope this will work ...If not give me your email Id,I will send you an example. :-O

Regards
Manuj Sharma


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

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