這裏就是我做的:自定義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