I think you don't even need a counter you can use a boolean as well and you can do it numerous ways:
public class MyProg
{
private int counter = 0;
private void myButton_click(object sender, EventArgs e) {
counter++;
}
}
=OR=
consider your button's text is 0.
protected void myButton_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
btn.Text = (Int32.Parse(btn.Text) + 1).ToString();
}
==========================EDIT==========================
Here is a more simplified code for you. You can write that function to the MyButtonHandler.
Button b1 = CreateMyButton();
b1.Click += new EventHandler(this.MyButtonHandler);
...
void MyButtonHandler(object sender, EventArgs e) {
...
}
Good luck,
OI