事件跟進這個問題:的WinForms爲繼承控件的UI風格
Winforms Style/UI Look and Feel Tips
所以我創建了我的「基本控制」,從其他控件繼承。爲了測試,我正在嘗試更改基本標籤的一種字體。但它不會傳播到從它繼承的控件。在其中一個窗體上,我可以看到設計器文件正在設置控件的屬性,所以我的基本控件的屬性被覆蓋。
在基本控件的我使用構造函數來設置默認屬性。我應該使用不同的事件嗎?如果是,哪一個。
下面是根據意見要求基本控制的一個代碼...
Public Class InfoLabel
Inherits Label
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.Font = New System.Drawing.Font("Tahoma", 14.25!)
Me.ForeColor = System.Drawing.Color.FromArgb(CType(CType(49, Byte), Integer), CType(CType(97, Byte), Integer), CType(CType(156, Byte), Integer))
Me.AutoSize = False
End Sub
End Class
基地控制顯示上的WinForm的編輯器項目工具箱。控件然後從工具箱拖放。
發表一些代碼,描述沒有幫助。 – 2009-02-26 16:31:49
代碼示例添加了更多評論。 – 2009-02-26 16:50:45