Guest User

Untitled

a guest
Jul 16th, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. this.comboBox1.BackColor = System.Drawing.Color.White; //or any other color
  2. this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; //it has to be that style
  3.  
  4. private void radioButton1_EnabledChanged(object sender, EventArgs e)
  5. {
  6. if (((ComboBox)sender).Enabled)
  7. {
  8. // set BackColor for enabled state
  9. }
  10. else
  11. {
  12. // set BackColor for disabled state
  13. }
  14. }
  15.  
  16. public class ComboBoxCustom : ComboBox {
  17. [DllImport("gdi32.dll")]
  18. internal static extern IntPtr CreateSolidBrush(int color);
  19.  
  20. [DllImport("gdi32.dll")]
  21. internal static extern int SetBkColor(IntPtr hdc, int color);
  22.  
  23. protected override void WndProc(ref Message m){
  24. base.WndProc(ref m);
  25. IntPtr brush;
  26. switch (m.Msg){
  27.  
  28. case (int)312:
  29. SetBkColor(m.WParam, ColorTranslator.ToWin32(this.BackColor));
  30. brush = CreateSolidBrush(ColorTranslator.ToWin32(this.BackColor));
  31. m.Result = brush;
  32. break;
  33. default:
  34. break;
  35. }
  36. }
  37. }
Add Comment
Please, Sign In to add comment