如何使用 C# 覆盖我的控件?
需要设置按钮属性,如
Font(Name => Segoe UI, style => Regular, size => 10), height => 50px, width => 250px, back color => green
默认。
如何对受尊重的按钮属性使用覆盖方法。
注意:我将在我的项目中使用 Windows 控件库控件。提前致谢。
如何使用 C# 覆盖我的控件?
需要设置按钮属性,如
Font(Name => Segoe UI, style => Regular, size => 10), height => 50px, width => 250px, back color => green
默认。
如何对受尊重的按钮属性使用覆盖方法。
注意:我将在我的项目中使用 Windows 控件库控件。提前致谢。
您可以使用默认属性进行自定义控件的覆盖。
自定义按钮的示例按钮代码:
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace DemoControls
{
[ToolboxItem(true)]
public class SimpleButton : Button
{
public SimpleButton()
{
Font = new Font("Segoe UI", 10, FontStyle.Regular);
Height = 50;
BackColor = DefaultBackColor;
}
}
}
当您构建项目时,它将在您的工具箱中显示控件,然后您必须在您想要的项目中使用此 SimpleButton