CodeCentralShow Me

完整的示例项目在 DevExpress Code Central 数据库中可用,网址是 http://www.devexpress.com/example=E1917。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。

本示例动态演示了 RibbonControls 的合并机制。 主/子 MDI 窗体都包含了 RibbonControls。 当子窗体被最大化时,子窗体的 RibbonControl 被合并到主窗体的 RibbonControl。

C#CopyCode image复制代码
 (Form1.cs)
private void Form1_Load(object sender, EventArgs e) {
    // Enable the form's title bar transparency
    //this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
    // Specify that the merge mechanism should be invoked when a child MDI form is maximized.
    this.ribbonControl1.MdiMergeStyle = RibbonMdiMergeStyle.OnlyWhenMaximized;
    CreateChildForm();
}
private void btnNew_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) {
    CreateChildForm();
}
int ctr = 1;
void CreateChildForm() {
    // Create an MDI child form, containing a RibbonControl
    ReportForm child = new ReportForm();
    child.Text = "Report " + ctr.ToString();
    child.MdiParent = this;
    child.Show();
    ctr++;
}
Visual BasicCopyCode image复制代码
 (Form1.vb)
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    ' Enable the form's title bar transparency
    'this.AllowFormGlass = DevExpress.Utils.DefaultBoolean.False;
    ' Specify that the merge mechanism should be invoked when a child MDI form is maximized.
    Me.ribbonControl1.MdiMergeStyle = RibbonMdiMergeStyle.OnlyWhenMaximized
    CreateChildForm()
End Sub
Private Sub btnNew_ItemClick(ByVal sender As Object, ByVal e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnNew.ItemClick
    CreateChildForm()
End Sub
Private ctr As Integer = 1
Private Sub CreateChildForm()
    ' Create an MDI child form, containing a RibbonControl
    Dim child As New ReportForm()
    child.Text = "Report " & ctr.ToString()
    child.MdiParent = Me
    child.Show()
    ctr += 1
End Sub