In my C# Windows Forms form I have some buttons which are dynamically generated. I assigned the following method on the click event. Is it possible to get the name of the button from which the event is triggered?
private void btnBrowsDoc_Click(object sender, EventArgs e)
{
try
{
if (openFileDialog1.ShowDialog().Equals(DialogResult.OK))
{
gbxDocument.Controls["txtDocument" + count].Text =
openFileDialog1.FileName;
}
else
{
return;
}
}
catch (Exception ex)
{
//handle the exception
}
}
See Question&Answers more detail:os