我在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) }更多推荐
发布评论