如何更新listview选择的项目,这是另一个窗体文本框 [英] how to update listview selected item which is another form textbox

查看:82
本文介绍了如何更新listview选择的项目,这是另一个窗体文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在form1中有两个表单,其中有文本框和一个保存按钮
在列表框上的form2中,当我单击列表框项时,我想在form1文本框中检索该项值,也想更新,但是我有
在form1

i have two forms in form1 have textboxes and one save button
in form2 on listbox when i click on listbox item i want to retrieve that item value in form1 textboxes as well as i want to update but i have
only one save button in form1

推荐答案

中只有一个保存按钮将文本框设置为公共.这将允许从任何其他类进行访问(您可以研究受保护的而不是公共的以获得更好的安全性),但是,表格2需要访问表格1的实例才能访问表格1的控件.您可以将表单2的构造函数更改为采用Form类型的对象,然后在表单1中打开表单2时,传递参数"this".然后,您可以通过表单2中的参数名称访问form1.textbox.text.

希望我不要让您感到困惑.如果需要的话,您基本上需要研究,公共/私人/受保护的证券,以及在实例内更改属性.
I''m not sure if i have understood you 100% but to retrieve data from another class (or form) you will need to set the textboxes as public. This will allow access from any other class (you can research protected instead of public for better security), however, form 2 needs to access the instance of form 1 in order for it to access form 1''s controls. You could alter the constructor of form 2 to take an object of type Form then when you open form 2 from within form 1 you pass the parameter ''this''. you can then access form1.textbox.text via the parameter name in form 2.

I hope i did not confuse you. If i did you basically need to research, public / private/ protected securities, and changing properties within an instance.


这篇关于如何更新listview选择的项目,这是另一个窗体文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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