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类说明。
DevExpress技术交流群3:700924826 欢迎一起进群讨论
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/2154.html