MDI形成问题 [英] MDI forms problem

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

问题描述

我在statusStrip中有一个父表单(IsMdicontainer = true),并且有一个带有按钮的孩子,我想在用户单击子表单中的按钮时更改statusStrip.text(在父表单中)的文本.
我该怎么做?请...
爱你们!

I have a parent form (IsMdicontainer=true) within a statusStrip , and a child with a button I wanna to change text of that statusStrip.text(in the parent form ) when the user clicks the button in the child form .
How can I do that guys? please...
Love u guys!

推荐答案

在这里-

回答:由于不了解如何实现事件,因此使用static并不是一个好的解决方案.
Re yogeshptl''s answer: Using static because you don''t understand how to implement events is not a good solution.


您可以轻松解决此问题. br/> 您以mdiparent形式创建一个更改statustrip文本的公共方法
这样的
void ChangeText(String s)
{
//更改文字代码.
}

创建一个mdiparent的静态对象
例如.
公共静态MDIParent1 objMDIParent1;

在表单加载事件上对其进行初始化
objMDIParent1 = this;


在子表单上调用ChangeText方法
例如


MDIParent1 .objMDIParent1.ChangeText("Some Tex");
you can easily solve this problem.
you create a public method in mdiparent form that changes statustrip text
like that
void ChangeText(String s)
{
//code for change text.
}

create a static object of mdiparent
eg.
public static MDIParent1 objMDIParent1;

initialise it on form load event
objMDIParent1=this;

and
call ChangeText method on child form
eg


MDIParent1 .objMDIParent1.ChangeText ("Some Tex");


这篇关于MDI形成问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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