Hi ,
I am trying to make the text on the combobox appear in black when the
combobox is disabled. Since there is no easy way to it, i decided i had to
draw it myself. But the combobox OnPaint event paints only the border and the
button portion of the combobox. The textbox portion of the combobox was not
accessible. So i had to use Win32 functions to get an handle to the text box
portion of the combobox. But again the painting of the textbox portion of
the combobox works fine when the combobox is enabled but it does not work
when the control is disabled even though the OnPaint and the same code is
getting executed. Any ideas?
I am pating the piece of code i am using to draw on the textbox portion of
the combobox. Please excuse the colors in the code as it only for testing.
The code works fine when the combobox is enabled but not when it is disabled.
When disabled the textbox portion of the combobox always remains gray. Also
when enabled the painting in the code happenes only when the mouse enters the
textbox area of the combobox.
RECT rt = new RECT();
IntPtr hdl = FindWindowEx(this.Handle, IntPtr.Zero, "EDIT",
"\0");
GetWindowRect(hdl, out rt);
Graphics g = Graphics.FromHwnd(hdl);
Brush br = new SolidBrush(Color.Green);
g.FillRectangle(new SolidBrush(Color.Red), new RectangleF(0,
0, rt.right - rt.left, rt.bottom - rt.top));
g.DrawString("Cool", new Font("Ariel", 10), br, 0f, 0f);
Thank You,
Vish