[英]How to override button properies in C#(font, height, width, backcolor)
How to Override my controls using C#?如何使用 C# 覆盖我的控件?
Need to set button property like需要设置按钮属性,如
Font(Name => Segoe UI, style => Regular, size => 10), height => 50px, width => 250px, back color => green
by default.默认情况下。
How to use override method for respected button properties.如何对受尊重的按钮属性使用覆盖方法。
Note: I am going to use windows control library controls, to my projects.注意:我将在我的项目中使用 windows 控件库控件。 Thanks in advance.
提前致谢。
you can make your custom control for overriding with your default properties.您可以制作自定义控件以覆盖默认属性。
Sample button code for custom button:自定义按钮的示例按钮代码:
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;
}
}
}
It will show control in your toolbox when you build your project then you have to use this SimpleButton in your project where you want当您构建项目时,它将在您的工具箱中显示控件,然后您必须在项目中所需的位置使用此 SimpleButton
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.