这里就是我做的:自定义Windows的外观窗体组合框
Public Class ComboBox
Inherits System.Windows.Forms.ComboBox
Public Sub New()
SetStyle(ControlStyles.OptimizedDoubleBuffer _
Or ControlStyles.UserPaint, True)
End Sub
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
e.Graphics.FillRectangle(gradient, ClientRectangle)
// The preceding line is a simplification of about 50 lines of code.
If Not String.IsNullOrEmpty(Text) Then
Dim rect As New Rectangle(2, 0, Width - 2, Height)
Using format As New StringFormat()
format.LineAlignment = StringAlignment.Center
Using brush As New SolidBrush(ForeColor)
e.Graphics.DrawString(Text, Font, brush, rect, format)
End Using
End Using
End If
e.Graphics.FillPolygon(Brushes.Black, New Point() { _
New Point(Width - 5, Height \ 2 - 1), _
New Point(Width - 12, Height \ 2 - 1), _
New Point(Width - 9, Height \ 2 + 3)})
End Sub
End Class
我有两个问题:
- 它的高度始终是24
- 下拉列表的下降呈现与一个丑陋的Windows 3.1字体。
http://i56.tinypic.com/w1p4ph.png
你想做什么?为什么你不能使用常规的ComboBox? – Justin 2011-02-01 14:45:18
该公司聘请了一位艺术家。他画了东西。现在我必须执行它。 (之前你问:我不能使用WPF。) – 2011-02-01 14:56:17