日期:2014-05-17 浏览次数:21172 次
Private Sub ListBox1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles ListBox1.DrawItem
Dim datas As String() = sData
Dim rc As RectangleF = New RectangleF(e.Bounds.X + 3, e.Bounds.Y + 5, e.Bounds.Width - 5, e.Bounds.Height - 3)
Dim rc1 As Rectangle = New Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, e.Bounds.Width - 5, e.Bounds.Height - 3)
Dim myBrush As Brush = Brushes.Black
e.DrawBackground()
'在选定项目上绘制选定背景色
'e.DrawFocusRectangle ( )
Dim sf As StringFormat = New StringFormat()
sf.Alignment = StringAlignment.Near
'设定 ListBox 中项目名称的在矩形区域的排列对齐方式
'e.Graphics.DrawRectangle(New Pen(New SolidBrush(System.Drawing.Color.White), 1), rc1)
'以线条粗度为1,黑色画笔对绘制ListBox中的每一个项目的边框
e.Graphics.DrawString(sData(e.Index), New Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold), New SolidBrush(sColorData(e.Index)), rc, sf)
Select Case ListBox1.Items(e.Index.ToString)
Case "关于"
myBrush = Brushes.White
Case "界面背景"
myBrush = Brushes.White
Case Else
myBrush = Brushes.Black
End Select
e.Graphics.DrawString(ListBox1.Items(e.Index).ToString, New Font(FontFamily.GenericSansSerif, 8, FontStyle.Bold), myBrush, rc, sf)