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.
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"; } }}
Hello doctorwc,
Thank you for posting code snippets that describe what you have done and what you want to do. Thanks to it, I could reproduce the issue you are facing.
In order to make "Single Child" tab be always visible, it would be good to add a "Single Child" tab on parent's toolbarsmanager, to specify false for Office2007UICompatibility and to let them be merged. As to how to merge tabs, see the following document:
MDI Toolbar Merging https://ko.infragistics.com/help/winforms/wintoolbarsmanager-mdi-toolbar-merging
I created a modified sample. Please review it and feel free to let me know if you need additional assistance.
Best Regards,
Noriko I.Developer Support Engineer,Infragistics, Inc.