Changing foreground / background of disabled combobox

  • Thread starter Thread starter Brian Mitchell
  • Start date Start date
B

Brian Mitchell

Is it possible to change the fore and back colors of a combo box when its
enabled property is set to false? I need to lock the value of my combo boxes
(and still keep its color) but that control doesn't have a read-only
property.

Thanks!!
 
Hi Brian,

Did you set the colors in code when you enabled and disabled it, I do not
see the problem?

Cor
 
* "Cor Ligthert said:
Did you set the colors in code when you enabled and disabled it, I do not
see the problem?

The combobox will use Windows' default colors when drawn in disabled
mode.
 
Hi Herfried,

That I did not know, than we can support the sample from Ken is it not.

\\\By Ken Tucker
ListBox1.DrawMode = DrawMode.OwnerDrawFixed
Dim ff As FontFamily
For Each ff In FontFamily.Families
ListBox1.Items.Add(ff.Name)
Next
Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As
System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
Dim g As Graphics = e.Graphics
Dim s As String
Dim d As Date
Dim br As Brush = SystemBrushes.WindowText
Dim brBack As Brush
Dim rDraw As Rectangle
Dim bSelected As Boolean = CBool(e.State And DrawItemState.Selected)
rDraw = e.Bounds
rDraw.Inflate(-1, -1)
If bSelected Then
brBack = Brushes.LightBlue
g.FillRectangle(Brushes.LightBlue, rDraw)
g.DrawRectangle(Pens.Blue, rDraw)
Else
brBack = Brushes.White
g.FillRectangle(brBack, e.Bounds)
End If
br = Nothing
brBack = Nothing
rDraw = Nothing
///
 
Back
Top