Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There are two combo boxes on the windows form.
Inside the code depending on the click event of a button they both become enabled or disabled i.e.

cbo1.enabled = true;
cbo2.enabled = true;


or

cbo1.enabled = false;
cbo2.enabled = false;



When they are disabled, cbo2 is greyed out but although cbo1 is not changeable (i.e. it is disabled) cbo1 has a white background and only the text inside it is greyed out. cbo1 is not completely greyed out as same as cbo2.

Backcolor of both controls is set to Window in design mode
Forecolor of both controls is set to WindowText in design mode

Question:
Do you know why the cbo1 is not completely greyed out?
Thanks
Posted
Updated 7-May-12 23:22pm

Check whether the cbo1 is placed on another control !!
 
Share this answer
 
Pls share your full code to help you!
 
Share this answer
 
What may have happened is that the BackColor of the control is no longer the default, even though it looks as if it is.

This can happen when the color is changed to something and then changed back by selecting the default color name. This will have put the following line in the designer.cs file.
C#
this.cb01.BackColor = System.Drawing.SystemColors.Window;

When the control is really operating with it's default color setting that line will be missing.

I don't know why this causes a problem but it has the effect of making making the enabled and disabled colors the same.

To fix:
1) Bring up the form in the designer
2) Select cb01
3) Goto properties and right click on the BackColor
4) If the Reset option is available then Reset

This is the proper way to reset a designer property and should fix the problem.

Alan.
 
Share this answer
 
Hi, Re-set the properties and all worked.
Thank you all.
 
Share this answer
 
form load event u have enter

cbo1.enabled = true;
cbo2.enabled = true;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900