c# - Only first 2 controls get Click event assigned in tableLayoutPanel -


i have table seen on left in picture
enter image description here
populate using following

private void populatequestiontable()     {         answertable.controls.add(new button() { text = "1", font = new font("arial", 12) }, 0, 0);         answertable.controls.add(new label() { text = "a", font = new font("arial", 12) }, 1, 0);         answertable.controls.add(new label() { text = "b", font = new font("arial", 12) }, 2, 0);         answertable.controls.add(new label() { text = "c", font = new font("arial", 12) }, 3, 0);         answertable.controls.add(new label() { text = "d", font = new font("arial", 12) }, 4, 0);         answertable.controls.add(new label() { text = "e", font = new font("arial", 12) }, 5, 0);         for( int = 1; < 50; i++ )         {             answertable.rowcount = answertable.rowcount + 1;             answertable.rowstyles.add(new rowstyle(sizetype.absolute, 40));              answertable.controls.add(new button() { text = convert.tostring(i + 1), font = new font("arial", 12) }, 0, i);             answertable.controls.add(new label() { text = "a", font = new font("arial", 12) }, 1, i);             answertable.controls.add(new label() { text = "b", font = new font("arial", 12) }, 2, i);             answertable.controls.add(new label() { text = "c", font = new font("arial", 12) }, 3, i);             answertable.controls.add(new label() { text = "d", font = new font("arial", 12) }, 4, i);             answertable.controls.add(new label() { text = "e", font = new font("arial", 12) }, 5, i);         }          (int = 0; < 50; i++)             (answertable.getcontrolfromposition(0, i) button).click += showquestion;     }   

yet first , second button fire click event when clicked.
i'm kind of new c#, knowledge of might limited. there limit number of controls might have function assigned them?
if not, wrong code wrote?


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -