Is there a way in C# to create a design template for a component (a button for example) All the buttons in the project will inherit the design from the template. And whenever I change the template all the buttons will inherit the change. I want that my application will have the same look all the buttons will look the same, all the text box..... Thanks

有帮助吗?

解决方案

what you want to do can be achieved by creating your own inherited class of a control. e.g.

public class yourbuttontemplate : System.Windows.Forms.Button
{
    yourbuttontemplate() //constructor
    {
        this.Height=20;
        this.Width=40;
        this.BackColor=Color.Blue;
    }
}

Once you build your project, your button should be available in the toolbox and you can use this button instead of the default Windows.Forms.Button.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top