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
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