下图说明了一个示例Toolbar Form,在表单标题栏中带有不同类型的bar items(常规按钮、编辑项、检查项和外观菜单)。
将表单转换为工具栏表单
隐藏表单标题可以显示没有标题的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 Forms或在代码中创建新的工具栏表单,您需要手动创建这些组件。 C# [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 [Visual Basic .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()
DevExpress技术交流群3:700924826 欢迎一起进群讨论
|