乐趣区

关于winform:应用的工具栏太难看这个控件帮你提升应用颜值

点击获取工具 >>
Toolbar Form 是 XtraForm 的扩大版本,容许您将 bar items 间接增加到表单标题栏中。

下图阐明了一个示例 Toolbar Form,在表单标题栏中带有不同类型的 bar items(惯例按钮、编辑项、查看项和外观菜单)。

ToolbarForm 是 XtraForm 类的后辈,并共享其所有性能。

将表单转换为工具栏表单

要将规范或任何 DevExpress form 转换为工具栏表单,请调用智能标记菜单并抉择 “Convert to Toolbar Form” 选项。

暗藏表单题目

能够显示没有题目的 Toolbar Form(Form.Text 属性),为此请禁用 ShowText 设置。以下 ”Visual Studio Inspired UI Demo” DevExpress demo 屏幕截图阐明了没有可见题目的 Toolbar Form。

在设计时将 Bar Items 增加到 Form Title Bar 中

能够应用向床柜工具栏增加 bar items 的办法来填充 Toolbar Form 的标题栏:表单在其标题栏的两端都有两个能够包容我的项目的区域,单击 “[Add]” 按钮创立一个新的我的项目。

您能够在设计时拖放我的项目来重新排列它们,而后从一个标题栏区域挪动到另一个标题栏区域。

在 Code. Satellite 控件中创立 Toolbar Forms

Toolbar Form 具备两个必须的从属控件 – ToolbarFormControl 和 ToolbarFormManager。

  • ToolbarFormControl – 表单的标题栏,显示增加到其 ToolbarFormControl.TitleItemLinks 汇合的条形我的项目,应用 BarItem.Alignment 属性抉择此我的项目停靠在 ToolbarFormControl 的左边缘还是右边缘。
  • ToolbarFormManager – 表单的外部 BarManager,在 ToolbarFormControl 中显示的集体工具栏我的项目。

要将现有表单转换为 Toolbar Forms 或在代码中创立新的工具栏表单,您须要手动创立这些组件。

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()`

无关表单标题栏的更新信息,请参见 ToolbarFormControl 类阐明。

退出移动版