如何在另一种形式中找到一个表单的DataGridView? [英] How to find DataGridView of one form in another form?

查看:72
本文介绍了如何在另一种形式中找到一个表单的DataGridView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好



这里我面临Datagridview控件的问题,我在form2中有dgvAllowance(Datagridview控件名),现在我想调用这个form1按钮点击事件中的datagrid



怎么做



谢谢!

Hi All

Here i'm facing problem with Datagridview control,i'm having dgvAllowance(Datagridview control name) in form2, now i want to call this datagrid in form1 button click event

How to do it

Thanks !

推荐答案

您是否尝试更改数据网格视图的属性修饰符?



例如将其从私人更改为公共,您可以使用form2.dgvAllowance访问控件
have you tried to change the property "Modifiers" of data grid view?

e.g. change it from "private" to "public" and you are able to access the control with "form2.dgvAllowance"


不要。

如果你这样做那么,你将两个表单的设计锁定在一起 - 所以你不能在不考虑它对form1(以及最终可能最终使用它的任何其他代码)的影响的情况下对form2进行更改。



相反,使用Form2的属性将信息提供回form1,使用form2中的方法来影响DataGridView。
Don't.
If you do that, you "lock" the design of the two forms together - so you cannot make changes to form2 without considering it's effects on form1 (and any other code which may also end up using it).

Instead, use properties of Form2 to provide the information back to form1, and methods in form2 to affect the DataGridView.


这篇关于如何在另一种形式中找到一个表单的DataGridView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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