Determining the source of the click event dynamically
I have a set of buttons that are added dynamically. As the user keeps
clicking the buttons, new buttons are added to the window. I am using a
winforms. I am binding the onclick event of all these buttons to the same
function. I am using the following code.
System.EventHandler myEventHandle= new
System.EventHandler(this.Button_Clicked);
Once a new dynamic button is created I add the event handler with the
following code:
b1.Click += myEventHandle;
Now in the function Button_Clicked() I want to get the Button which
invoked this event. I want to disable this Button so that it cannot be
clicked again and I want the name of the Button that was clicked as I want
to do various actions depending on button name. I am newbie in C# can you
please help me out. Its urgent.
No comments:
Post a Comment