Form Customization in Windows Forms Form (SfForm)

25 May 20233 minutes to read

Form icon

A form icon designates the picture that represents the form in the taskbar as well as the icon displayed on the title bar of the form.

Changing form icon

The form icon displayed on the title bar and task bar can be changed by using the Icon property.

this.Icon = new Icon("sfIcon.ico");
Me.Icon = New Icon("sfIcon.ico")

WindowsForms Form shows icon

Form icon alignment

The form icon can be aligned vertically and horizontally by using the Style.TitleBar.IconVerticalAlignment and Style.TitleBar.IconHorizontalAlignment properties.

this.Style.TitleBar.IconVerticalAlignment = VerticalAlignment.Top;
this.Style.TitleBar.IconHorizontalAlignment = HorizontalAlignment.Right;
Me.Style.TitleBar.IconVerticalAlignment = VerticalAlignment.Top
Me.Style.TitleBar.IconHorizontalAlignment = HorizontalAlignment.Right

WindowsForms Form icon is alignment

Form border

Appearance of the border can be customized by using the Style.Border and Style.InactiveBorder properties.

//Customize active state border appearance
this.Style.Border = new Pen(Color.SkyBlue, 2);

//Customize inactive state border appearance
this.Style.InactiveBorder = new Pen(Color.LightGray, 2);
'Customize active state border appearance
Me.Style.Border = New Pen(Color.SkyBlue, 2)

'Customize inactive state border appearance
Me.Style.InactiveBorder = New Pen(Color.LightGray, 2)

WindowsForms Form with customized border color

Shadow effect

Shadow effect of the form can be customized by using the Style.ShadowOpacity and Style.InactiveShadowOpacity properties.

//Customize the shadow for active state
this.Style.ShadowOpacity = 255;

//Customize the shadow for inactive state
this.Style.InactiveShadowOpacity = 100;
'Customize the shadow for active state
Me.Style.ShadowOpacity = 255

'Customize the shadow for inactive state
Me.Style.InactiveShadowOpacity = 100

WindowsForms Form with shadow effect

NOTE

Shadow can be disabled by setting the ShadowOpacity property as zero.

Rounded corner

Rounded corners for SfForm can be enabled by using the AllowRoundedCorners property. Rounded corners are not supported in OS versions lower than Windows 11. Enabling AllowRoundedCorners property will have no effect on those operating systems.

NOTE

When the rounded corners are enabled, the border and shadow of the Form are drawn by the operating system.

this.AllowRoundedCorners = true;
Me.AllowRoundedCorners = true

WindowsForms Form with rounded corners