public Form1() { InitializeComponent(); foreach (Control item in MainPanel.Controls) { if (item is TextBox) { item.Click += text.Click; item.LostFocus += text.LostFocus; text.Add((TextBox)item); } } }
public SetFunction() { InitializeComponent(); ReturnButton.DialogResult = DialogResult.OK; TextBoxWork boxWork = new TextBoxWork(); foreach (Control item in MainPanel.Controls) { if (item is TextBox control) { control.Click += boxWork.Click; control.LostFocus += boxWork.LostFocus; boxWork.Add(control); } } }