简体   繁体   English

在Windows窗体中单击按钮时引发事件

[英]Raise an event when button is clicked in windows forms

I am making an user interface from windows forms (c#).In my form there are many buttons named enable (for enable each textbox).What i need to do here is when the button relevant to textbox is clicked enable the textbox.(they are not in a groupBox). 我正在从Windows窗体(c#)制作用户界面。在窗体中有许多名为enable(用于启用每个文本框的按钮)。我需要做的是单击与文本框相关的按钮时启用文本框。不在groupBox中)。 Without manually coding in each button click's method how can i do this in a programmatic way 没有在每个按钮单击的方法中手动编码,我该如何以编程方式进行此操作

Assuming you are trying to bind a textBox's enable property to a button, I would recommend you yo build a simple custom userConrol. 假设您尝试将textBox的enable属性绑定到按钮,则建议您构建一个简单的自定义userConrol。 Inside that control you will be able to bind the logic of the button to the TextBox. 在该控件内,您将能够将按钮的逻辑绑定到TextBox。 You can then add any number of that specific UserControl to your application and it will automaticly bind your button's logic to the textBox. 然后,您可以将任意数量的该特定UserControl添加到您的应用程序中,它将自动将按钮的逻辑绑定到textBox。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击任务栏中的按钮时,会向Windows窗体窗口发送什么事件? - What event is sent to a Windows Forms window when its button from the taskbar is clicked? 在 Windows 窗体应用程序中单击按钮时隐藏一个窗体并显示另一个窗体 - Hiding a form and showing another when a button is clicked in a Windows Forms application 在Windows窗体中单击“关闭”按钮时的事件处理程序 - An Event Handler when Close Button is clicked in windows form Windows窗体RichTextBox-由单词单击驱动的事件 - Windows Forms RichTextBox - Event driven by the word clicked on 单击按钮时,不会引发OnClientClick事件 - When clicking a button, the OnClientClick event does not raise 单击Return时,TextBox是否应该引发验证事件? - Should the TextBox raise the validating event when Return is clicked? 单击“ Enter”键时如何在树视图中引发事件 - How to raise event in treeview when “Enter” key clicked 在 System.Windows.Forms.DataGrid 中双击单元格时不会触发 MouseDoubleClick 事件 - MouseDoubleClick event is not fired when a cell is double-clicked in System.Windows.Forms.DataGrid 在Windows窗体设计器中双击控件时,是否有一种方法不自动生成单击事件逻辑? - Is there a way to not auto-generate the click event logic when a control is double-clicked in the Windows Forms designer? 单击时放大图像-Windows窗体 - Enlarging an Image when clicked - Windows Forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM