The application toolbar is too ugly? DevExpress Toolbar Form helps you improve the appearance of your application

Download DevExpress v20.2 full version

DevExpress Technical Exchange Group 3: 700924826 Welcome to join the group discussion

Toolbar Form is an extended version of XtraForm , allowing you to add bar items  directly to the form title bar.

The following figure illustrates a sample Toolbar Form with different types of bar items (regular buttons, edit items, check items, and appearance menus) in the title bar of the form.

DevExpress WinForms help documentation

ToolbarForm is a descendant of the XtraForm class and shares all its functions.

Convert form to toolbar form

To convert a standard or any DevExpress form to a toolbar form, please call the smart tag menu and select the "Convert to Toolbar Form" option.

DevExpress WinForms help documentation

Hide form title

You can display the Toolbar Form without a title (Form.Text property). For this, please disable the ShowText setting. The following screenshot of the "Visual Studio Inspired UI Demo" DevExpress demo illustrates the Toolbar Form without a visible title.

DevExpress WinForms help documentation

Add Bar Items to Form Title Bar at design time

You can use the method of adding bar items to the bed cabinet toolbar to fill the title bar of the Toolbar Form: The form has two areas at both ends of the title bar that can hold items, click the "[Add]" button to create a new one project.

DevExpress WinForms help documentation

You can drag and drop items at design time to rearrange them, and then move from one title block area to another.

Create Toolbar Forms in the Code. Satellite control

Toolbar Form has two necessary subsidiary controls-  ToolbarFormControl and ToolbarFormManager .

  • ToolbarFormControl  -The title bar of the form, which displays the bar items added to its ToolbarFormControl.TitleItemLinks collection. Use the BarItem.Alignment property to select whether this item is docked at the left or right edge of the ToolbarFormControl.
  • ToolbarFormManager  -The internal BarManager of the form , the personal toolbar item displayed in the ToolbarFormControl.

To convert existing forms to Toolbar Forms or to create new toolbar forms in code, you need to create these components manually.

C#

ToolbarForm myForm = new ToolbarForm();
myForm.Size = new Size(800, 600);
myForm.Text = "Toolbar Form";
ToolbarFormManager tfcManager = new ToolbarFormManager() { Form = myForm };
ToolbarFormControl tfcHeader = new ToolbarFormControl() { ToolbarForm = myForm, Manager = tfcManager};
myForm.Controls.Add(tfcHeader);
myForm.ToolbarFormControl = tfcHeader;

//create four buttons
BarButtonItem item1 = new BarButtonItem(tfcManager, "Button 1");
BarButtonItem item2 = new BarButtonItem(tfcManager, "Button 2");
BarButtonItem item3 = new BarButtonItem(tfcManager, "Button 3");
BarButtonItem item4 = new BarButtonItem(tfcManager, "Button 4");
//buttons 3 and 4 will be docked to the ToolbarFormControl's right edge
item3.Alignment = item4.Alignment = BarItemLinkAlignment.Right;

//Out of two items added to the TitleItemLinks collection, the item that was added first
//will be closer to the form edge. For that reason, you need to populate the right area
//backwards, i.e. start with rightmost item 
tfcHeader.TitleItemLinks.AddRange(new BarItem[] { item1, item2, item4, item3});

myForm.Show();

VB.NET

Dim myForm As New ToolbarForm()
myForm.Size = New Size(800, 600)
myForm.Text = "Toolbar Form"
Dim tfcManager As New ToolbarFormManager() With {.Form = myForm}
Dim tfcHeader As New ToolbarFormControl() With {.ToolbarForm = myForm, .Manager = tfcManager}
myForm.Controls.Add(tfcHeader)
myForm.ToolbarFormControl = tfcHeader

'create four buttons
Dim item1 As New BarButtonItem(tfcManager, "Button 1")
Dim item2 As New BarButtonItem(tfcManager, "Button 2")
Dim item3 As New BarButtonItem(tfcManager, "Button 3")
Dim item4 As New BarButtonItem(tfcManager, "Button 4")
'buttons 3 and 4 will be docked to the ToolbarFormControl's right edge
item4.Alignment = BarItemLinkAlignment.Right
item3.Alignment = item4.Alignment

'Out of two items added to the TitleItemLinks collection, the item that was added first
'will be closer to the form edge. For that reason, you need to populate the right area
'backwards, i.e. start with rightmost item 
tfcHeader.TitleItemLinks.AddRange(New BarItem() { item1, item2, item4, item3})

myForm.Show()

For updated information about the form title bar, please refer to the ToolbarFormControl class description.


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

Guess you like

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