且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在VB.NET中从子窗体中更改窗口主窗体的控件值

更新时间:2023-11-30 15:35:10

在你的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.