[英]how to change another form name in button click event
I am working on windows form application ... 我正在处理Windows窗体应用程序...
I have two forms .. 1->frm master 2->frm shifting 我有两种形式.. 1-> frm master 2-> frm shift
i have a OK button in frm shifting..while i cliking the button i want o change the name of frmmaster
我在frm shift中有一个OK按钮
frmmaster
我按下按钮我想要更改frmmaster
的名字
frmmaster is the my parent form frmmaster是我的父母表格
so i given code in Ok button event like thise 所以我在像Ok一样的Ok按钮事件中给出了代码
frmmaster.Text="NewName"
but this is not working.. while coming to this line am getting error: Object reference not set to an instance of an object. 但这不起作用..虽然来到这一行我得到错误: 对象引用未设置为对象的实例。
put this on your child form's click event: 把它放在你孩子表单的点击事件上:
Form form = Application.OpenForms["frmmaster"];
form.Text="lol";
Try this: 尝试这个:
((your frmName)this.MdiParent).Text = "SomeText":
like 喜欢
((frmMaster)this.MdiParent).Text = "SomeText"
or 要么
Make sure when you create your child form you assign an MDI parent to it. 确保在创建子表单时为其分配MDI父表单。
//Open form in frmMaster
frmShifter.MdiParent = this;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.