Reputation: 646
I am looking for a implementation for my Windows Application, where i can apply similar style to all similar controls (like same style for all the Buttons).
This implementation should be only in Windows Form ( not WPF). And no third party libraries/ controls.
Something like a custom control for button, and all the Buttons will inherit from the custom control.
Thanks!
Upvotes: 0
Views: 2948
Reputation: 3636
foreach (Control ctr in this.Controls) {
ctr.Color = Colors.Red;
.
.
.
}
etc
You can have this kind of code in a separate style-class and pass your forms to it, thus making the style-class alter the components of the forms the way you wish.
Upvotes: 0
Reputation: 941227
Drag a rectangle around the controls so they all get selected. Ctrl+Left Click to adjust the selection. Change the property. Or create your own 'styled' button control by using class inheritance. Derive your own class from the Button class, change the properties in the constructor:
using System;
using System.Windows.Forms;
internal class MyButton : Button {
public MyButton() {
this.FlatStyle = FlatStyle.Flat;
// etc..
}
}
Override methods to alter behavior and appearance. After you compile, the new control is available at the top of the toolbox.
Upvotes: 2