Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
125
Locking a merged ribbons tab(s)
posted

I have an MDI parent form with toolbars manager/ribbon that creates a singleton child form which has it's own ribbon that gets merged into the parent.

I also have other child forms with their own ribbon layout.

When I switch between forms the parent ribbon merges things correctly (ie. Click on child 1 and it's tab layout appears, click on child 2 and the same occurs).

However - I would like to know if I can "pin" or "lock" the tab layout of 1 of the children.

I will only ever create a single instance of child 1 and would like it's tab layout to be there all the time, with other child tab layouts being dynamically merged as is the default behavior.

Any help would be appreciated.

Parents
  • 125
    Offline posted

    Here's an example app.. a "Singleton" tab is created when it starts up that lists the files in the application directory inside a grid.

    Double-clicking on a row will cause a child form to be added to the app.

    Switching between the "Singleton" tab and the file-based forms will change the parent ribbon to only display either the "Single Child" tab or the "Multi Child" tab.

    What I want is for the "Single Child" tab to always be visible.

    using System;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;
    using Infragistics.Win;
    using Infragistics.Win.UltraWinGrid;
    using Infragistics.Win.UltraWinTabbedMdi;
    using Infragistics.Win.UltraWinTabs;
    using Infragistics.Win.UltraWinToolbars;

    namespace TabTesting
    {
    static class Program
    {
    [STAThread]
    static void Main()
    {
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new ParentForm());
    }
    }

    class ParentForm : Form
    {
    private UltraToolbarsManager _toolbars = new UltraToolbarsManager();
    private UltraTabbedMdiManager _mdiManager = new UltraTabbedMdiManager();
    private SingleChildForm _singleChild = new SingleChildForm();

    public ParentForm()
    {
    IsMdiContainer = true;
    _toolbars.DockWithinContainer = this;
    _toolbars.Ribbon.Visible = true;
    _mdiManager.MdiParent = this;
    _singleChild.MdiParent = this;
    _singleChild.Show();

    var tab = _mdiManager.TabFromForm(_singleChild);
    tab.Settings.AllowClose = DefaultableBoolean.False;
    tab.Settings.CloseButtonVisibility = TabCloseButtonVisibility.Never;
    Size = new Size(640, 480);
    }
    }

    class SingleChildForm : Form
    {
    private UltraToolbarsManager _toolbars = new UltraToolbarsManager();
    private UltraGrid _grid = new UltraGrid();

    public SingleChildForm()
    {
    _toolbars.DockWithinContainer = this;
    _toolbars.Ribbon.Visible = true;
    var tab = _toolbars.Ribbon.Tabs.Add("SingleTab");
    tab.Caption = "Single-Child";
    Text = "Singleton";

    _grid.DataSource = Directory.GetFiles(Application.StartupPath);
    _grid.Dock = DockStyle.Fill;
    _grid.DoubleClickRow += GridOnDoubleClickRow;
    _grid.DisplayLayout.Override.CellClickAction = CellClickAction.RowSelect;
    _grid.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
    Controls.Add(_grid);
    }

    private void GridOnDoubleClickRow(object sender, DoubleClickRowEventArgs e)
    {
    var child = new MultiChildForm
    {
    MdiParent = ParentForm,
    Text = Path.GetFileName((string)e.Row.ListObject)
    };
    child.Show();
    }
    }

    class MultiChildForm : Form
    {
    private readonly UltraToolbarsManager _toolbars = new UltraToolbarsManager();

    public MultiChildForm()
    {
    _toolbars.DockWithinContainer = this;
    _toolbars.Ribbon.Visible = true;
    var tab = _toolbars.Ribbon.Tabs.Add("MultiTab");
    tab.Caption = "Multi-Child";
    }
    }
    }

Reply Children
No Data