我对MetroFramework ComboBox使用DrawItem事件有问题。以前,我使用的是默认的vb 2015 system.windows.form.ComboBox,并且DrawItem事件正在运行,并且在使用MetroFramework之后不会触发DrawItem事件。
Private Sub ComboBox_Counter_DrawItem(ByVal sender As System.Object,
ByVal e As System.Windows.Forms.DrawItemEventArgs) _
Handles ComboBox_Counter.DrawItem
On Error Resume Next
MsgBox("Here")
e.DrawBackground()
Dim drv As DataRowView = CType(ComboBox_Counter.Items(e.Index), DataRowView)
Dim id As Integer = drv("counterNo").ToString()
Dim name As String = drv("description").ToString()
Dim r1 As Rectangle = e.Bounds
r1.Width = r1.Width / 6
Using sb As SolidBrush = New SolidBrush(e.ForeColor)
e.Graphics.DrawString(id, e.Font, sb, r1)
End Using
Using p As Pen = New Pen(Color.Black)
e.Graphics.DrawLine(p, r1.Right, 0, r1.Right, r1.Bottom)
End Using
Dim r2 As Rectangle = e.Bounds
r2.X = e.Bounds.Width / 6
r2.Width = r2.Width '/ 2
Using sb As SolidBrush = New SolidBrush(e.ForeColor)
e.Graphics.DrawString(name, e.Font, sb, r2)
End Using
End Sub