
将combobox的属性DrowMode设置成OwnerDrawVariable,添加两个事件就OK了!
Private Sub m_cboOperScale_DrawItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DrawItemEventArgs) Handles m_cboOperScale.DrawItem
If e.Index < 0 Then
Exit Sub
End If
e.DrawBackground()
e.DrawFocusRectangle()
e.Graphics.DrawString(m_cmbContents.Items(e.Index).ToString, e.Font, New SolidBrush(e.ForeColor), e.Bounds)
End Sub
Private Sub m_cboOperScale_MeasureItem(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs) Handles m_cboOperScale.MeasureItem
e.ItemHeight = 20
End Sub
自定义ComboBox样式
本文介绍如何通过设置ComboBox的DrawMode属性为OwnerDrawVariable,并添加DrawItem与MeasureItem事件处理程序来实现自定义ComboBox的显示样式。
3万+

被折叠的 条评论
为什么被折叠?



