I need to know if it is possible to store click event of a button in
a variable. I tried doing it but didn't get any solution.

Please help


Event name it self a reference/delegate type variable and you can assign a reference of method (called event handler) to it using (+=) operator.

Please show us your code .

Thanks for your reply.

i haven't written any code yet.
Let me explain you why i need this.

suppose i have two forms; form1 and form2.

on form1 i have 4 buttons. All these buttons open
form2 on click. In form2 i have a data grid view which shows data
of tables(has same name that of button). Now how do i
put this in form2 that which table to show, unless it(form2) knows which button was clicked.

(hey sorry if you find this confusing).


Create a new constructor for Form2 that takes a string parameter and store the value in Form2:

String whatTable;

public Form2(String table) {
    whatTable = table;

Now in your button click event you create the form and tell it which table:

Form2 myForm2 = new Form2("GameTable");