事件跟进这个问题:的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