Class SfForm
Represents a window or dialog box that makes up an application's user interface with options to customize its appearance.
Namespace: Syncfusion.WinForms.Controls
Assembly: Syncfusion.Shared.Base.dll
Syntax
public class SfForm : Form, IThemeProvider, IVisualStyle
Constructors
SfForm()
Initializes a new instance of the SfForm class.
Declaration
public SfForm()
Properties
AccessibilityEnabled
Gets or sets a value indicating whether the accessibility is enabled for the Form or not.
Declaration
public bool AccessibilityEnabled { get; set; }
Property Value
Type |
---|
System.Boolean |
AllowRoundedCorners
Gets or sets a value indicating whether the rounded corners are enabled.
Declaration
public bool AllowRoundedCorners { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is false. |
Remarks
This option is only in effect with Windows 11.
BackColor
Gets or sets the back color of the form.
Declaration
public override Color BackColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
CanApplyTheme
Gets or sets a value indicating whether a SkinManager theme style settings can be applied to the control.
Declaration
public bool CanApplyTheme { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
CanOverrideStyle
Gets or sets a value indicating whether control elements styles can be overridden by theme style settings.
Declaration
public bool CanOverrideStyle { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | Default value is false. |
Remarks
By default, the control's element styles will not be overridden by theme style settings if the style is set in sample level. If this property is enabled, element style will be overridden by theme style settings event if it is set in sample level. This property should be enabled or disabled before calling the ThemeName property of the control.
CloseButtonVisible
Gets or sets a value indicating whether the close button is displayed in the caption bar of the form.
Declaration
public bool CloseButtonVisible { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
ForeColor
Gets or sets the fore color of the form.
Declaration
public override Color ForeColor { get; set; }
Property Value
Type |
---|
System.Drawing.Color |
IconSize
Gets or sets a value indicating the size of the form icon.
Declaration
public Size IconSize { get; set; }
Property Value
Type |
---|
System.Drawing.Size |
IsVisualStyleEnabled
Gets a value indicating whether the visual style based theme is applied to the control and also indicates whether the theme files are referred from external assemblies or not.
Declaration
public bool IsVisualStyleEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean | Return true, if the visual style based theme is applied to the control. Otherwise returns false. |
Padding
Gets or sets padding within the form.
Declaration
public Padding Padding { get; set; }
Property Value
Type |
---|
System.Windows.Forms.Padding |
ShowToolTip
Gets or sets a value indicating whether the tooltip for the title bar button is enabled.
Declaration
public bool ShowToolTip { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean | The default value is true. |
Style
Gets the FormVisualStyle value used to customize the appearance of the form.
Declaration
public FormVisualStyle Style { get; }
Property Value
Type |
---|
FormVisualStyle |
ThemeName
Gets or sets the theme name of the SfForm.
Declaration
public string ThemeName { get; set; }
Property Value
Type |
---|
System.String |
TitleBarHeightMode
Declaration
public CaptionBarHeightMode TitleBarHeightMode { get; set; }
Property Value
Type |
---|
CaptionBarHeightMode |
TitleBarTextControl
Gets or sets the control to be displayed in the title bar of the form instead of the title bar text.
Declaration
public Control TitleBarTextControl { get; set; }
Property Value
Type | Description |
---|---|
System.Windows.Forms.Control | The default value is null. |
Remarks
Form.Text property value will be displayed on the title bar only when this property value is equal to null.
Examples
//Loads a Button control to the title bar of the form.
TitleBarTextControl = new Button();
//Sets the text for the TitleBarTextControl.
TitleBarTextControl.Text = "Control1";
VisualTheme
Gets or sets the visual theme, which holds the ThemeName applied from SkinManager.
Declaration
protected string VisualTheme { get; set; }
Property Value
Type |
---|
System.String |
Methods
BeginUpdate()
Suspends the painting of the control until the EndUpdate() method is called.
Declaration
public void BeginUpdate()
Examples
//Call BeginUpdate() to ensure the form is painted only once.
this.BeginUpdate();
//Change the appearance of the form.
this.Style.TitleBar.ForeColor = Color.Red;
this.Style.TitleBar.BackColor = Color.SkyBlue;
//Call EndUpdate() when finish changing the appearance of the form.
this.EndUpdate();
CreateAccessibilityInstance()
Overridden to set the accessibility object for the SfForm.
Declaration
protected override AccessibleObject CreateAccessibilityInstance()
Returns
Type | Description |
---|---|
System.Windows.Forms.AccessibleObject | Returns the accessibility object of the SfForm. |
Dispose(Boolean)
Clean up any resources being used.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | true if managed resources should be disposed; otherwise, false. |
EndUpdate()
Resumes the painting of the control suspended by calling the BeginUpdate() method.
Declaration
public void EndUpdate()
Examples
//Call BeginUpdate() to ensure the form is painted only once.
this.BeginUpdate();
//Change the appearance of the form.
this.Style.TitleBar.ForeColor = Color.Red;
this.Style.TitleBar.BackColor = Color.SkyBlue;
//Call EndUpdate() when finish changing the appearance of the form.
this.EndUpdate();
GetActiveThemeName()
Gets the active theme name of the SfForm.
Declaration
public string GetActiveThemeName()
Returns
Type | Description |
---|---|
System.String | Returns the active theme name. |
GetControlName()
Gets the control name.
Declaration
protected virtual string GetControlName()
Returns
Type |
---|
System.String |
OnHandleCreated(EventArgs)
Occurs when the form handle is created.
Declaration
protected override void OnHandleCreated(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | The System.EventArgs that contains the event data. |
OnLoad(EventArgs)
Raises the System.Windows.Forms.Form.Load event.
Declaration
protected override void OnLoad(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | args | Event Arguments. |
OnShown(EventArgs)
Raises the System.Windows.Forms.Form.Shown event.
Declaration
protected override void OnShown(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.EventArgs | e | Event args that contains the event data |
SetBoundsCore(Int32, Int32, Int32, Int32, BoundsSpecified)
Set the specified bound for the form.
Declaration
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The Left property value of the form. |
System.Int32 | y | The Top property value of the form. |
System.Int32 | width | The Width property value of the form. |
System.Int32 | height | The Height property value of the form. |
System.Windows.Forms.BoundsSpecified | specified | Specifies the bounds of the form. |
SetClientSizeCore(Int32, Int32)
Sets the client size of the form. This will adjust the bounds of the form to make the client size the requested size.
Declaration
protected override void SetClientSizeCore(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Requested width of the client region. |
System.Int32 | y | Requested height of the client region. |
WndProc(ref Message)
Processes Windows messages.
Declaration
protected override void WndProc(ref Message m)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.Forms.Message | m | Windows message. |
Events
ThemeNameChanged
Occurs when theme name of the SfForm has been changed.
Declaration
public event ThemeChangedEventHandler ThemeNameChanged
Event Type
Type |
---|
ThemeChangedEventHandler |
Explicit Interface Implementations
IVisualStyle.VisualTheme
Gets or sets the VisualTheme of the SfForm.
Declaration
string IVisualStyle.VisualTheme { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.BaseThemeName
Gets or sets the base theme name of the SfForm.
Declaration
string IThemeProvider.BaseThemeName { get; set; }
Returns
Type |
---|
System.String |
IThemeProvider.ControlName
Gets the name of the control.
Declaration
string IThemeProvider.ControlName { get; }
Returns
Type |
---|
System.String |