简体   繁体   English

如何在按钮单击事件中更改另一个表单名称

[英]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.

相关问题 如何通过单击另一个表单的按钮来更改一个表单中的按钮的文本? - How to change the Text of a Button in One form with a Button click of another Form? 如何将按钮单击事件更改为输入事件? - How to change button click event into enter event? 如何检查按钮是否在C#中的Windows窗体应用程序中的另一个按钮单击事件内被单击 - how to check whether a button is clicked, inside another button click event in windows form application in C# 在另一个表单的按钮单击事件后刷新另一个表单datagridview - Refreshing another forms datagridview upon button click event of another form 如何创建表单方法的按钮单击事件? - how to create button click event for form method? 如何使用代码更改按钮单击事件 - how to change button click event using code 如何从另一个处理程序调用/调用按钮单击事件处理程序? (C# ) - How Do I invoke/call a button click event handler form another handler? (c# ) 呼叫按钮单击事件从一种Web表单转移到另一种Web表单 - Call button click event from one web form to another 从另一个表单的按钮单击事件访问后台工作者 - Accessing background worker from another form's button click event 查找DGV按钮列的单击事件并转移到另一个表单 - Finding the click event of DGV button column and transferring to another form
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM