Tuesday 15 March 2011

winforms - C# dynamically delete checkboxes -



winforms - C# dynamically delete checkboxes -

i'm trying delete checked checkboxes groupbox pressing button. after want rest checkboxes in order.

here code deleting checkboxes:

private void button2_click(object sender, eventargs e) { for(int i=0; i<=number_ch; i++) { foreach(control c in groupbox2.controls) { if(c.gettype().name=="checkbox") { if(((checkbox)c).checked==true) { groupbox2.controls.remove(c); number_ch--; } } } } }

it works how set rest in order?

you should not delete controls, create them visible=false !

c# winforms dynamic checkbox

No comments:

Post a Comment