DevExpress WinForms Help Document: Form Control-Introduction to XtraForm

Download DevExpress v20.2 full version

Go to DevExpress Chinese website to get first-hand latest product information!

To achieve a consistent UI throughout the application, the standard WinForms dialogs, forms, and message boxes must be replaced with the forms corresponding to their DevExpress. This section will introduce you to XtraForms that replaces the default project form.

DevExpress WinForms help documentation

  • Add XtraForms to the project
  • Convert standard forms to XtraForms
  • Apply skin to form title bar
  • Glow and shadow effects
  • Increase border width
  • MDI title bar title

Add XtraForms to the project

The fastest way to start a project with XtraForm as the main form is to use DevExpress templates that support UI . All these templates are based on DevExpress forms. Specifically, toolbar-based templates and "Blank Application" templates use XtraForms.

DevExpress WinForms help documentation

To add new XtraForms, right-click on your project in the Solution Explorer window of Visual Studio and select "Add DevExpress Item | New Item...". This will call the Template Gallery with the new project template , select the "Form" template, enter the form name, and click "Add Item".

DevExpress WinForms help documentation

Convert standard forms to XtraForms

To replace the existing default form with XtraForms, please call form smart-tags and select the "Convert to Skinable Form" option.

DevExpress WinForms help documentation

To perform the same operation in code, just change the base class of the form derived from System.Windows.Forms.Form to DevExpress.XtraEditors.XtraForm. You also need to include the DevExpress.XtraEditors library in your project.

C#

using DevExpress.XtraEditors;

namespace DXApplication1 {
public partial class Form1 : XtraForm {
public Form1() {
InitializeComponent();
}
}
}

VB.NET

Imports DevExpress.XtraEditors

Namespace DXApplication1
Partial Public Class Form1
Inherits XtraForm

Public Sub New()
InitializeComponent()
End Sub
End Class
End Namespace

Apply skin to form title bar

If you use the DefaultLookAndFeel  component to skin the application, all the required code lines will be automatically added to the Main() method of the Project.cs file. In this case, you do nothing, and the form title bar (and all controls on this form) will be drawn according to the activated skin.

Otherwise, if you apply the skin in your code, please manually call the static SkinManager.EnableFormSkins  and/or  SkinManager.EnableMdiFormSkins methods.

DevExpress WinForms help documentation

C#

using DevExpress.Skins;
// ... 
SkinManager.EnableFormSkins();
SkinManager.EnableMdiFormSkins();

VB.NET

Imports DevExpress.Skins;
' ... 
SkinManager.EnableFormSkins()
SkinManager.EnableMdiFormSkins()

Glow and shadow effects

The XtraForm.FormBorderEffect property allows you to activate the glow or shadow effect of the form.

Set the property to FormBorderEffect.Shadow  to enable the form shadow. In order to brighten or darken the shadow, assign a byte value between 0 and 255 to the FormShadow.Opacity property.

DevExpress WinForms help documentation

C#

this.FormBorderEffect = DevExpress.XtraEditors.FormBorderEffect.Shadow;
this.FormShadow.Opacity = 120;

VB.NET

Me.FormBorderEffect = DevExpress.XtraEditors.FormBorderEffect.Shadow
Me.FormShadow.Opacity = 120

When you set the XtraForm.FormBorderEffect property to FormBorderEffect.Glow , the Form glow effect will be activated. This setting applies a soft gloss to the border of the form. The form can glow in two colors, depending on whether it is currently selected. These colors are assigned to the XtraForm.ActiveGlowColor and XtraForm.InactiveGlowColor properties.

DevExpress WinForms help documentation

C#

this.FormBorderEffect = DevExpress.XtraEditors.FormBorderEffect.Glow;
this.ActiveGlowColor = Color.Lime;

VB.NET

Me.FormBorderEffect = DevExpress.XtraEditors.FormBorderEffect.Glow
Me.ActiveGlowColor = Color.Lime

Increase border width

Enabling the WindowsFormsSettings.FormThickBorder or WindowsFormsSettings.MdiFormThickBorder properties can expand the XtraForm border and expand the resizing area. Please note that these settings will affect all XtraForms and RibbonForms in the application.

DevExpress WinForms help documentation

If the shadow\glow effect is turned off, and the default window resizing area is too small, the border will become larger to make it easier for users to adjust the size of the window.

MDI title bar title

If enabled, if the XtraForm.ShowMdiChildCaptionInParentTitle option is enabled, the title of the child MDI form will be merged with the title bar of the parent form. The following figure illustrates an example: the "document1" string is displayed next to the parent form's own "Form1" title.

DevExpress WinForms help documentation

To change the default "<child_form_caption>-<parent_form_caption>" format string, please use the XtraForm.MdiChildCaptionFormatString property.


DevExpress Technical Exchange Group 2: 775869749 Welcome to join the group discussion

Guess you like

Origin blog.csdn.net/AABBbaby/article/details/112002682