[COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] ListBoxColorsDrawItem([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] System.Object, _
[COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.Windows.Forms.DrawItemEventArgs) _
[COLOR=#0000ff]Handles[/COLOR] ListBoxColors.DrawItem
[COLOR=#0000ff]Dim[/COLOR] lb [COLOR=#0000ff]As[/COLOR] ListBox = [COLOR=#0000ff]DirectCast[/COLOR](sender, ListBox)
[COLOR=#0000ff]Dim[/COLOR] rect [COLOR=#0000ff]As[/COLOR] Rectangle = e.Bounds
[COLOR=#0000ff]Dim[/COLOR] item [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]String[/COLOR] = lb.Items(e.Index).ToString
[COLOR=#0000ff]Dim[/COLOR] b [COLOR=#0000ff]As[/COLOR] [COLOR=#0000ff]New[/COLOR] SolidBrush(Color.FromName(item))
e.DrawBackground()
e.Graphics.DrawRectangle(Pens.Silver, rect)
rect.Width = rect.Height
rect.Inflate(-2, -2)
e.Graphics.FillRectangle(b, rect)
b.Dispose()
b = [COLOR=#0000ff]New[/COLOR] SolidBrush(e.ForeColor)
rect = e.Bounds
e.Graphics.DrawString(item, lb.Font, b, rect.Left + lb.ItemHeight + 4, rect.Top + 2)
[COLOR=#0000ff]If[/COLOR] e.State = DrawItemState.Selected [COLOR=#0000ff]Then[/COLOR] e.DrawFocusRectangle()
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR]
[COLOR=#0000ff]Private[/COLOR] [COLOR=#0000ff]Sub[/COLOR] FormMain_Load([COLOR=#0000ff]ByVal[/COLOR] sender [COLOR=#0000ff]As[/COLOR] System.Object, [COLOR=#0000ff]ByVal[/COLOR] e [COLOR=#0000ff]As[/COLOR] System.EventArgs) _
[COLOR=#0000ff]Handles[/COLOR] [COLOR=#0000ff]MyBase[/COLOR].Load
ListBoxColors.ItemHeight = 17
[COLOR=#0000ff]For[/COLOR] [COLOR=#0000ff]Each[/COLOR] c [COLOR=#0000ff]As[/COLOR] KnownColor [COLOR=#0000ff]In[/COLOR] [Enum].GetValues([COLOR=#0000ff]GetType[/COLOR](KnownColor))
[COLOR=#0000ff]If[/COLOR] c > KnownColor.YellowGreen [COLOR=#0000ff]Or[/COLOR] c < KnownColor.AliceBlue [COLOR=#0000ff]Then[/COLOR] [COLOR=#0000ff]Continue[/COLOR] [COLOR=#0000ff]For[/COLOR]
ListBoxColors.Items.Add(c.ToString)
[COLOR=#0000ff]Next[/COLOR]
[COLOR=#0000ff]End[/COLOR] [COLOR=#0000ff]Sub[/COLOR]