Dear Friend,
First of all, i think the problem is that you want to act to the event of changing the Enabled/Disabled state
of the combobox (which is changed in the design time) using the event "ComboBox_EnabledChanged"
(which is executed in the runtime), so you got now the reason of the problem?
So, what is the turn around to overcome this problem?
You can so the following,
You can override the event "comboBox1_Layout", and write the following code:
private void comboBox1_Layout(object sender, System.Windows.Forms.LayoutEventArgs e)
{
if(comboBox1.Enabled)
{
comboBox1.BackColor = Color.FromKnownColor(KnownColor.Window);
}
else
{
comboBox1.BackColor = Color.Yellow;
}
}
As a result, when the combobox is loaded on the form, this event check its state,
and it turns its backcolor according to this state
Try it and fell free to send your comments
Hope this helps
|