如何在VB.NET中从子窗体中更改窗口主窗体的控件值 [英] How to change windows main form's control values from child form in VB.NET

查看:97
本文介绍了如何在VB.NET中从子窗体中更改窗口主窗体的控件值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生/ s



我从该表单获得主窗口表格我打电话给另一个表格。



Dear Sir/s

I have main windows form from that form i am calling another form.

dim frm as new frmchild(loginid)
frm.show()





现在来自此子表单我想更新主表单的文本框值。

请帮帮我,我已经尝试了很多。



调试时显示值在主表单上更改但实际上它没有反映新值。



谢谢



< b>我尝试了什么:


主表单上的
我使用了一个更新主表单文本框值的计时器。这个计时器我启用了它儿童表格。



frmmain.timer1.enabled = true

此计时器启用后立即启用timer1更新文本框值。



now from this child form i want to update textbox value of main form.
Please help me i have tried a lot.

while debugging is shows values are changed but actual on the main form it does not get reflected new values.

Thanks

What I have tried:

on main form i had use one timer which update textbox value of main form.and this timer i enabled it on child form.

frmmain.timer1.enabled=true
as soon this timer get enabled timer1 update textbox value.

推荐答案

在你的chi中创建一个事件主表单处理的ld表单: https://msdn.microsoft .com / zh-CN / library / ms172877.aspx?f = 255& MSPPError = -2147217396 [ ^ ] - 当您的孩子想要更新主表单时,它会引发事件。

向子项添加属性以返回要更新的数据。

在主窗体事件处理程序中,通过子窗体的实例访问属性 - 通过保存实例当您在上面显示的代码中创建它时,或者通过sender参数创建处理程序方法时。然后主表单用新数据更新自己。
Create an Event in your child form which the Main form handles: https://msdn.microsoft.com/en-us/library/ms172877.aspx?f=255&MSPPError=-2147217396[^] - when your child wants to update the main form, it raises the event.
Add a property to the child to return the data that you want you update with.
In the main form event handler, access the property via the instance of the child form - either by saving the instance when you create it in the code you show above, or via the sender parameter to the handler method. The main form then updates itself with the new data.


这篇关于如何在VB.NET中从子窗体中更改窗口主窗体的控件值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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