【发布时间】:2023-03-25 12:43:02
【问题描述】:
跟进这个问题:
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 编辑器的项目工具箱中。然后从工具箱中拖放控件。
标签: winforms user-interface controls