Loading...
Loading...
Implements Syncfusion MetroForm control for creating modern Metro-styled Windows Forms with customizable caption bars, borders, and colors. Use this when working with MetroForm, custom title bars, flat UI forms, or modernizing Windows Forms appearance. The skill provides guidance for caption bar customization, rounded corners, caption labels and images, and advanced styling features.
npx skill4agent add syncfusion/winforms-ui-components-skills syncfusion-winforms-metroformFormInstall-Package Syncfusion.Shared.BaseSyncfusion.Shared.Base.dllusing Syncfusion.Windows.Forms;
namespace MyApplication
{
// Inherit from MetroForm instead of Form
public partial class MainForm : MetroForm
{
public MainForm()
{
InitializeComponent();
// Basic configuration
this.Text = "My Metro Application";
this.CaptionBarHeight = 40;
this.CaptionBarColor = Color.FromArgb(17, 158, 218);
this.CaptionForeColor = Color.White;
this.BorderColor = Color.FromArgb(17, 158, 218);
this.BorderThickness = 2;
}
}
}Imports Syncfusion.Windows.Forms
Namespace MyApplication
' Inherit from MetroForm instead of Form
Public Partial Class MainForm
Inherits MetroForm
Public Sub New()
InitializeComponent()
' Basic configuration
Me.Text = "My Metro Application"
Me.CaptionBarHeight = 40
Me.CaptionBarColor = Color.FromArgb(17, 158, 218)
Me.CaptionForeColor = Color.White
Me.BorderColor = Color.FromArgb(17, 158, 218)
Me.BorderThickness = 2
End Sub
End Class
End Namespace// Create and configure caption label
CaptionLabel captionLabel = new CaptionLabel();
captionLabel.Text = "Dashboard";
captionLabel.Font = new Font("Segoe UI", 10F, FontStyle.Regular);
captionLabel.ForeColor = Color.White;
captionLabel.Size = new Size(200, 24);
// Add to form
this.CaptionLabels.Add(captionLabel);// Create and configure caption image
CaptionImage logoImage = new CaptionImage();
logoImage.Image = Properties.Resources.AppLogo;
logoImage.Location = new Point(10, 5);
logoImage.Size = new Size(32, 32);
logoImage.BackColor = Color.Transparent;
// Handle click event
logoImage.ImageMouseDown += (sender, e) =>
{
MessageBox.Show("Logo clicked!");
};
// Add to form
this.CaptionImages.Add(logoImage);// Apply gradient brush to caption bar
this.CaptionBarBrush = new LinearGradientBrush(
new Rectangle(0, 0, this.Width, this.CaptionBarHeight),
Color.DarkBlue,
Color.LightBlue,
LinearGradientMode.Horizontal
);
// Optional: Custom paint event for more control
this.CaptionBarPaint += (sender, e) =>
{
using (var brush = new LinearGradientBrush(
e.ClipRectangle,
Color.DarkBlue,
Color.LightBlue,
LinearGradientMode.Horizontal))
{
e.Graphics.FillRectangle(brush, e.ClipRectangle);
}
};// Enable rounded corners (Windows 11 only)
this.AllowRoundedCorners = true;
this.BorderColor = Color.FromArgb(17, 158, 218);CaptionBarHeightCaptionBarColorCaptionForeColorCaptionFontCaptionAlignCaptionVerticalAlignmentCaptionBarHeightModeBorderColorBorderThicknessAllowRoundedCornersCaptionButtonColorCaptionButtonHoverColorCaptionLabelsCaptionImagesIconAlignCaptionBarBrushthis.Text = "Analytics Dashboard";
this.CaptionBarHeight = 50;
this.CaptionBarColor = Color.FromArgb(41, 128, 185);
// Add company logo
CaptionImage logo = new CaptionImage
{
Image = Resources.CompanyLogo,
Location = new Point(10, 10),
Size = new Size(30, 30)
};
this.CaptionImages.Add(logo);
// Add title label
CaptionLabel title = new CaptionLabel
{
Text = "Real-Time Analytics",
Font = new Font("Segoe UI Semibold", 11F),
ForeColor = Color.White
};
this.CaptionLabels.Add(title);this.Text = "Settings";
this.CaptionBarHeight = 35;
this.CaptionBarColor = Color.FromArgb(52, 73, 94);
this.CaptionForeColor = Color.White;
this.BorderColor = Color.FromArgb(52, 73, 94);
this.BorderThickness = 1;
this.FormBorderStyle = FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;// Gradient caption bar
this.CaptionBarBrush = new LinearGradientBrush(
new Rectangle(0, 0, this.Width, this.CaptionBarHeight),
Color.FromArgb(44, 62, 80),
Color.FromArgb(52, 152, 219),
LinearGradientMode.Horizontal
);
// Caption buttons
this.CaptionButtonColor = Color.White;
this.CaptionButtonHoverColor = Color.FromArgb(231, 76, 60);
// Add user info to caption
CaptionLabel userLabel = new CaptionLabel
{
Text = "Welcome, John Doe",
ForeColor = Color.White,
Font = new Font("Segoe UI", 9F),
Location = new Point(100, 10)
};
this.CaptionLabels.Add(userLabel);CaptionBarPaintImageMouseDownImageMouseUpImageMouseEnterImageMouseLeaveImageMouseMoveMetroFormFormSyncfusion.Shared.Base.dllSyncfusion.Windows.FormsCaptionBarHeightAllowRoundedCorners = true