从父表单访问子表单的控件 [英] Accessing controls of a child form from parent form

查看:95
本文介绍了从父表单访问子表单的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何从父表单访问子表单中的标签.

Hi

How to access the label in the child form from the parent form.?

推荐答案

没有子表单"和父表单".这是拥有的表单"及其所有者.
尝试在所有情况下都使用这种关系.

对于他们的协作,这种关系根本不重要.
请在这里查看我的答案:
如何在列表框之间复制所有项目两种形式 [ ^ ].查看整个讨论-可能非常有用.

—SA
There is no "Child form" and "Parent form". This is "Owned form" and its Owner.
Try to use this relationship in all cases.

This relationship does not matter at all when it comes to their collaboration.
Please see my Answer here:
How to copy all the items between listboxes in two forms[^]. See the whole discussion — can be very useful.

—SA


要添加到其他答案中,请勿直接以其他形式访问控件.而是以目标形式公开一个公共属性,或者公开一个呼叫者可以挂接到的公共事件,以监听进行更改.
To add to the other answers, do not directly access a control in a different form. Instead expose a public property in the target form, or alternatively expose a public event that callers can hook on to, to listen for changes.


您应该尝试过由您自己或至少教程:Visual Studio Windows应用程序在父窗体和子窗体之间传递数据 [
You should have tried by your own or atleast Googled[^] it.

One of the links, look this as a sample:
Tutorial: Visual Studio Windows Application Passing Data Between Parent And Child Forms[^]


这篇关于从父表单访问子表单的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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