从多个表单实例处理单个实例(Manipulate a single instance from a multiple instance of a form)

编程入门 行业动态 更新时间:2024-10-27 10:33:01
从多个表单实例处理单个实例(Manipulate a single instance from a multiple instance of a form)

我在C#中有一个类,即一个表单,可以多次实例化。 每次实例化表单时,其所有文本框都是只读的。 我还有一个带有edit_button的菜单栏。 应该发生什么; 当我专注于单个表单并按下菜单栏上的edit_button时,该特定表单的只读文本框变得可编辑,但仅适用于具有焦点的表单。 其余的没有焦点,不会受到影响。 我不能给出示例代码,因为我不知道如何去做。 你能帮我吗? 谢谢。

I have a class i.e., a form, in C# that can be instantiated multiple times. Each time that the form is instantiated, all of its textboxes are readonly. I also have a Menubar that has an edit_button. What should happen is; when I focus on a single form and press the edit_button on the menu bar, the readonly textboxes of that particular form becomes editable but only for that form that has the focus. The rest, which does not have focus, will not be affected. I can't give a sample code because I do not know how to go about it. Can you help? Thank you.

最满意答案

根据您的描述,似乎菜单栏与所有多种形式分开......这是一个MDI应用程序吗?

如果是这样,在编辑按钮单击处理程序中,您可以执行以下操作:

var activeForm = this.ActiveMdiChild; // assuming 'this' is the parent MDI form foreach(var control in activeForm.Controls) { // do something here (enable textboxes) }

Given your description it seems the menubar is separate from all the multiple forms... is this an MDI application?

If so, in your edit button click handler, you can do something like this:

var activeForm = this.ActiveMdiChild; // assuming 'this' is the parent MDI form foreach(var control in activeForm.Controls) { // do something here (enable textboxes) }

更多推荐

本文发布于:2023-08-07 14:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464913.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实例   多个   表单   Manipulate   form

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!