我如何访问另一种形式的一种形式的属性 [英] How ca i access properties of one form in another form
本文介绍了我如何访问另一种形式的一种形式的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经采用一种形式的gridview并进行了sql连接并显示了所有数据.现在我采用了另一种形式并将值从gridview传递给Second form文本框.在这里我想对数据进行更改(插入,更新,删除).
但是我不是以第二种形式访问gridview.任何人都可以帮助我
i have taken gridview in one form and taken the sql connection and displayed the all data.Now i have taken another form and pass the values from gridview to Second form textboxes. Here i want to make changes to data(Insert,update,delete).
But i am not accessing gridview in second form.any one can help me
推荐答案
不要这样做.
您可以通过声明public
而不是private
来将GridView从一种形式公开给其他形式,但这不是一个好主意-它将两种形式联系在一起,这样一种形式就不会改变而不会影响另一种形式.这违反了OOP的原则.
而是提供一个public
属性或方法,该属性或方法接受更改并将其传递到GridView中.这样一来,表单的内部结构就不会暴露出来,并且可以被应用程序的其他部分重复使用.
Don''t do it.
You can expose the GridView from one form to others, by declaring itpublic
instead ofprivate
but it is not a good idea - it ties the two forms together so that one form cannot change without affecting the other. This is against the principles of OOP.
Instead, provide apublic
property or method which accepts the changes and passes them into the GridView. That way, the internals of the form are not exposed and it can be re-used by other parts of your app.
这篇关于我如何访问另一种形式的一种形式的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文