public MyThemedForm() { // Required for Windows Form Designer support InitializeComponent(); // Set the FlatStyle for all controls SetFlatStyleSystem(this); }void SetFlatStyleSystem(Control parent) { foreach( Control control in parent.Controls ) { // Only these controls have a FlatStyle property ButtonBase button = control as ButtonBase; GroupBox group = control as GroupBox; Label label = control as Label; if( button != null ) button.FlatStyle = FlatStyle.System; else if( group != null ) group.FlatStyle = FlatStyle.System; else if( label != null ) label.FlatStyle = FlatStyle.System; // Set contained controls FlatStyle, too SetFlatStyleSystem(control); } }参阅 Windows Forms Programming in C# 2.7.3章节。
// Required for Windows Form Designer support
InitializeComponent(); // Set the FlatStyle for all controls
SetFlatStyleSystem(this);
}void SetFlatStyleSystem(Control parent) {
foreach( Control control in parent.Controls ) {
// Only these controls have a FlatStyle property
ButtonBase button = control as ButtonBase;
GroupBox group = control as GroupBox;
Label label = control as Label;
if( button != null ) button.FlatStyle = FlatStyle.System;
else if( group != null ) group.FlatStyle = FlatStyle.System;
else if( label != null ) label.FlatStyle = FlatStyle.System; // Set contained controls FlatStyle, too
SetFlatStyleSystem(control);
}
}参阅
Windows Forms Programming in C#
2.7.3章节。