Disabled ComboBox Text

S

Stephen Muecke

To overcome the hard-to-read text associated with a disabled combobox, I
have created my own and overriden the OnEnabledChanged method as follows
(note the control also includes a DisabledBackColor property)

Protected Overrides Sub OnEnabledChanged(ByVal e As System.EventArgs)
'Call base method so delegates receive event (must do this first for
remaining code to work)
MyBase.OnEnabledChanged(e)
'Set BackColor
If Not MyBase.Enabled Then
'Set back color
MyBase.BackColor = m_DisabledBackColor
'Get the controls editbox
Dim hwnd As IntPtr = GetWindow(MyBase.Handle, GW_CHILD) 'GW_CHILD
= &H5
'Enable it so it adopts the controls BackColor and displays text in
normal ForeColor
SendMessage(hwnd, WM_ENABLE, 1, 0) 'WM_ENABLE = &H100
Else
'Set back color to original
MyBase.BackColor = m_BackColor
End If
End Sub

This works great except if the DropDownStyle is set to DropDownList, in
which case the text reverts to the faded style.
Can anyone offer any suggestions as to how I can make this work with a
DropDownList style?

Stephen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top