I create new textbox controls with my application and when i click on such control i would like to know the name of the control.
I know how i get all the names of the controls with a loop.
But i want only know the name off the control i clicked.
The code to generate the control:
nieuweTextBox.Name = "nieuweTextBox_" + aantal;
nieuweTextBox.Text = nieuweTextBox.Name.ToString();
nieuweTextBox.Left = e.X - this.Left;
nieuweTextBox.Top = e.Y - this.Top-15;
nieuweTextBox.Click += new System.EventHandler(this.test);
Controls.Add(nieuweTextBox);
aantal = aantal + 1;
The function test is at this time:
private void test(object sender, System.EventArgs e)
{
Type typeOfObject = sender.GetType();
foreach (Control tempCtrl in Controls)
{
//this.Controls.Remove(tempCtrl);
MessageBox.Show(tempCtrl.Name.ToString(),"Informatie");
}
}
But i want only the name of the control i clicked....
thanx