删除另一种形式的datagridview的记录 [英] Deleting the records of datagridview of another form

查看:97
本文介绍了删除另一种形式的datagridview的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种形式的按钮,即MDIParent和DGV,另一种形式.要通过单击某些条件来单击MDI中的删除按钮来删除DGV的记录.我不想要frmForm frm = new frmForm()
任何人都可以帮助我提出一些想法.

在Advance中致谢

I have a button in one form which is MDIParent and DGV in another form. Want to delete the records of DGV on click of the delete button in MDI, by checking some conditions. I dont want the frmForm frm = new frmForm()
Anyone can help me with some idea.

Thanks in Advance

推荐答案

您可以通过两种方式处理此问题-它们都涉及以包含DGV的形式进行的工作.
第一种是以表单的形式创建属性或方法,该属性或方法被赋予要删除的行的标识.然后,通过引用子窗体创建时的实例来调用它.

另一个是以孩子所订阅的父表单形式提供一个事件.父级通知事件(可能使用自定义EventArgs传递要删除的记录的标识),然后子级处理该事件,删除记录.

就个人而言,我会选择第二个选项.
There are two way you can handle this - and they both involve the work being done in the form containing the DGV.
The first is to create a property or method in the form, which is given the identity of the row to delete. You then call this by reference to the instance of the child form from when it was created.

The other is to provide an event in the parent form to which the child subscribes. The parent signals the event (possibly with a custom EventArgs to pass through the identity of the records to remove) and teh child handles it, deleting the records.

Personally, I would go with the second option.


这篇关于删除另一种形式的datagridview的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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