Progammically change multiple buttons with for loop C# -
im trying this:
list<int> listname = new list<int>(); for(int i; <= listname[0];i++) { button(i).enabled = false; }
... disable buttons 1 i. best way of doing this?
thanks.
there few ways bulk modify controls.
example 1 (putting them in list)
list<button> buttonstodisable = new list<button>() { button1, button2 }; foreach (var button in buttonstodisable) { button.enabled = false; }
example 2 (putting them in same container iterating on controls in container)
foreach(var button in groupbox1.controls.oftype<button>()) { button.enabled = false; }
example 3 (subfixing controls id)
list<int> buttonsubfixid = new list<int>() { 1, 2 }; foreach (var id in buttonsubfixid) { var controls = this.controls.find("button" + id.tostring(), true).oftype<button>(); if (controls.count()>0) { foreach (var button in controls) { button.enabled = false; } } }
Comments
Post a Comment