Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- this.comboBox1.BackColor = System.Drawing.Color.White; //or any other color
- this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; //it has to be that style
- private void radioButton1_EnabledChanged(object sender, EventArgs e)
- {
- if (((ComboBox)sender).Enabled)
- {
- // set BackColor for enabled state
- }
- else
- {
- // set BackColor for disabled state
- }
- }
- public class ComboBoxCustom : ComboBox {
- [DllImport("gdi32.dll")]
- internal static extern IntPtr CreateSolidBrush(int color);
- [DllImport("gdi32.dll")]
- internal static extern int SetBkColor(IntPtr hdc, int color);
- protected override void WndProc(ref Message m){
- base.WndProc(ref m);
- IntPtr brush;
- switch (m.Msg){
- case (int)312:
- SetBkColor(m.WParam, ColorTranslator.ToWin32(this.BackColor));
- brush = CreateSolidBrush(ColorTranslator.ToWin32(this.BackColor));
- m.Result = brush;
- break;
- default:
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment