|
-
October 27th, 2011, 05:10 PM
#1
setting combo-box to enable/disable in a code...
I have a form (frmMain) with one panel, 3 buttons and a combo box (this is outside of the panel)..
is there a way to enable/disable the combo-box when one of the buttons is enabled (say button 1 is enable, i want the combo-box to be enabled too, and if this same box is disabled, the combo box should be disabled too).
right now i do a loop:
Code:
foreach (Control ctrl in this.Controls)
{
if (ctrl is ComboBox)
{
ComboBox cb = (ComboBox)ctrl;
if (cb.Name == "cmbDocumentClasses")
{
cb.Enabled = false;
break;
}
}
}
since I know that there is only one combo box in the form, is there another way to just go directly to this combo-box and set it to Enabled = false?
Thanks in advance.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|