Private Sub mItem1_DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles mItem1.DrawItem, mItem2.DrawItem
Dim fselected As Boolean = CType(e.State And DrawItemState.Selected, Boolean)
Dim g1 As Graphics = e.Graphics
Dim p1 As Point
p1.X = e.Bounds.X : p1.Y = e.Bounds.Y
'////全部的区域
Dim mRect As New Rectangle(e.Bounds.Left + 1, e.Bounds.Top, e.Bounds.Width - 2, e.Bounds.Height)
'////除外框的填充区域
Dim mRectFill As New Rectangle(e.Bounds.Left + 2, e.Bounds.Top + 1, e.Bounds.Width - 2 - 1, e.Bounds.Height - 1)
If fselected Then '选中
e.Graphics.DrawRectangle(New Pen(SystemColors.ControlDarkDark), mRect)
'g1.DrawLine(New Pen(Color.White), e.Bounds.Left + 2, e.Bounds.Top + CType(e.Bounds.Height - 2, Integer), e.Bounds.Left + e.Bounds.Width - 2, e.Bounds.Top + CType(e.Bounds.Height - 2, Integer))
'g1.DrawLine(New Pen(Color.White), e.Bounds.Left + 2, e.Bounds.Top + CType(e.Bounds.Height - 1, Integer), e.Bounds.Left + e.Bounds.Width - 2, e.Bounds.Top + CType(e.Bounds.Height - 1, Integer))
Else
If CType(e.State And DrawItemState.HotLight, Boolean) Then
'mouse 移动到的图型
e.Graphics.DrawRectangle(New Pen(Color.FromArgb(10, 36, 106)), mRect)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(182, 189, 210)), mRectFill)
Else
'正常状态的图形
e.Graphics.DrawRectangle(New Pen(Color.FromArgb(212, 208, 200)), mRect)
e.Graphics.FillRectangle(New SolidBrush(Color.FromArgb(212, 208, 200)), mRectFill)
End If
End If
g1.DrawString(sender.text, e.Font, New SolidBrush(Color.Black), p1.X + 2, p1.Y + 3)
End Sub
Private Sub mItem1_MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles mItem1.MeasureItem, mItem2.MeasureItem
Dim mStringFormat As New StringFormat
mStringFormat.HotkeyPrefix = Drawing.Text.HotkeyPrefix.Show
e.ItemWidth = CInt(e.Graphics.MeasureString(Me.Text, Me.Font, 1000, mStringFormat).Width) + 2 * 4
'处理快捷键(ShortCut)
'e.ItemHeight = 10
End Sub