I'm confused on this because this works fine in VS 2008 on winXP sp2/sp3 but in VS 2008 on Vista sp1/sp2 I'm getting an Invalid Parameter exception on this line:
Here' the whole sub:
The combobox is filled with the names of colors from the colors enum.
Anyone know why?
VB.NET:
e.Graphics.DrawString(aColor.Name, Me.Font, br, e.Bounds.Height + 5I, ((e.Bounds.Height - Me.Font.Height) \ 2I) + e.Bounds.Top)
VB.NET:
Protected Overrides Sub onDrawItem(ByVal e As System.Windows.Forms.DrawItemEventArgs)
e.DrawBackground()
e.DrawFocusRectangle()
If e.Index >= 0I Then
' Get the Color object from the Items list
Dim aColor As Color = CType(Me.Items(e.Index), Color)
' get a square using the bounds height
Dim rect As Rectangle = New Rectangle(5I, e.Bounds.Top + 2I, e.Bounds.Height - 3I, e.Bounds.Height - 5I)
Dim br As Brush = If((e.State And DrawItemState.Selected) = DrawItemState.Selected, Brushes.White, Brushes.Black)
' draw a rectangle and fill it
Using pn As New Pen(aColor)
e.Graphics.DrawRectangle(pn, rect)
End Using
Using b As New SolidBrush(aColor)
e.Graphics.FillRectangle(b, rect)
End Using
' draw a border
rect.Inflate(1I, 1I)
e.Graphics.DrawRectangle(Pens.Black, rect)
' draw the Color name
e.Graphics.DrawString(aColor.Name, Me.Font, br, e.Bounds.Height + 5I, ((e.Bounds.Height - Me.Font.Height) \ 2I) + e.Bounds.Top)
br.Dispose()
End If
End Sub
Anyone know why?