访问/设置属性 [英] accessing / setting properties

查看:79
本文介绍了访问/设置属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何以其他形式访问/设置控件的属性。

即mdi孩子的mdi父母

mdi child mdi孩子的朋友

mdi孩子的mdi父母


谢谢

Alex

解决方案

你好Alex,


你需要引用另一个表格。


每个孩子都有一个MdiParent属性,这很好,很简单。

父母Form有一个MdiChildren集合,你必须翻找

in才能找到一个特定的孩子表格。


问候,

Fergus


Fergus,

嗯......我在MdiParent和来自孩子的状态栏中有一个状态栏

Me.MdiParent.stBar.Text =" some text"给我错误


stBar不是System.Windows.Forms.Form的成员。


我做错了什么?


谢谢

Alex

Fergus Cooney写道:

你好Alex,
你需要引用另一个表格。

每个孩子都有一个MdiParent属性,这很好,很简单。
父表单有一个MdiChildren集合,你必须要翻找
在寻找特定的孩子表格。

问候,
Fergus




"阿莱克斯" < AI ****** @ hotmail.com> schrieb

Fergus,
嗯......我在MdiParent和孩子身​​上有一个状态栏
调用Me.MdiParent.stBar.Text =some text"给我错误

stBar不是System.Windows.Forms.Form的成员。

我做错了什么?




Me.MdiParent的类型是System.Windows.Forms.Form。 stBar不是Form类的成员

。如果孩子的类型总是相同,你可以使用类型转换:


Directcast(Me.MdiParent,<类型名称container>)。s​​tBar.Text =" some

text"

恕我直言,更好的方法是在孩子中举起一个活动并抓住它

MdiParent。在事件处理程序中,父级设置状态栏的文本。

-

Armin


Hi,
how can I access / set properties of controls in other forms.
i.e. mdi parent of mdi child
mdi child of mdi child
mdi child of mdi parent

Thanks
Alex

解决方案

Hi Alex,

You need to have a reference to the other Form.

Each child has an MdiParent property which is nice and straightforward.
The parent Form has an MdiChildren collection which you''ll have to rummage
in to find a specific child Form.

Regards,
Fergus


Fergus,
hmm... I have a status bar in the MdiParent and from the child calling
Me.MdiParent.stBar.Text = "some text" gives me the error

stBar is not a member of System.Windows.Forms.Form.

What am I doing wrong ?

Thanks
Alex
Fergus Cooney wrote:

Hi Alex,

You need to have a reference to the other Form.

Each child has an MdiParent property which is nice and straightforward.
The parent Form has an MdiChildren collection which you''ll have to rummage
in to find a specific child Form.

Regards,
Fergus




"alex" <ai******@hotmail.com> schrieb

Fergus,
hmm... I have a status bar in the MdiParent and from the child
calling Me.MdiParent.stBar.Text = "some text" gives me the error

stBar is not a member of System.Windows.Forms.Form.

What am I doing wrong ?



The type of Me.MdiParent is System.Windows.Forms.Form. stBar is not a member
of the Form class. If the type of the child will always be the same, you
can use type casting:

Directcast(Me.MdiParent, <type name of the container>).stBar.Text = "some
text"
IMHO, the better approach is to raise an event in the child and catch it in
the MdiParent. In the event handler the parent sets the text of the statusbar.
--
Armin


这篇关于访问/设置属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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