I'm currently stuck on the following: I have ~500 textboxes which I want to display information when clicked, however doing this seperately for each textbox would take way too long.
I have tried the following, using an array which contains all textboxes in my WinForm. However, I can't seem to get it to work.
var textBoxes = new List<Control>();
foreach (Control c in Controls)
{
if (c is TextBox)
{
textBoxes.Add(c);
}
}
foreach(var c in textBoxes)
{ c.Click += textBox_Click();
}
public void textBox_Click(object sender, EventArgs e)
{ string location = c.Text;
MessageBox.Show(location);
}
I hope that someone can help me out, thanks!