Well the task wasn't as simple as I expected. The main problem revolved around the clash between EnableGroups() and ShowTabWorkspace.
I attach a variation of the c# sample "MDISample" with a menu option called "Show Document Tab". Selecting this will toggle tabbed view and multiple document view.
N.B. I cannot use EnableGroups() in this code - it stops ShowTabWorkspace from working.
The key code is in a helper function
#region Helper functions
private void ChangeDocType(bool TabbedDocs)
{
m_TabbedDocs = TabbedDocs;
if (m_TabbedDocs == true) //tabbed document display
{
m_Workspace = CommandBars.ShowTabWorkspace(true);
m_Workspace.Refresh();
foreach (Form ctrl in this.MdiChildren)
{
ctrl.FormBorderStyle = FormBorderStyle.None;
ctrl.WindowState = https://forum.codejock.com/uploads/20061114_153426_MDISample_2.zip - System.Windows.Forms.FormWindowState.Maximized;
}
foreach (XtremeCommandBars.TabControlItem tci in CommandBars.TabWorkspace)
{
//MessageBox.Show(tci.Caption + " : " + tci.Handle.ToString() + " : ");
//need to loop through the tabs and select them so that the form is redisplayed correctly
//in the tab.
m_Workspace.FindItem(tci.Handle).Selected = true;
}
}
else //multi document display
{
m_Workspace = CommandBars.ShowTabWorkspace(false);
m_Workspace.Refresh();
foreach (Form ctrl in this.MdiChildren)
{
//making the form invisible and then visible makes sure that it is redrawn correctly.
//N.B. make sure that the form is not set to AutoSize
ctrl.Visible = false;
ctrl.AutoSize = false;
ctrl.FormBorderStyle = FormBorderStyle.Sizable;
ctrl.StartPosition = FormStartPosition.CenterParent;
ctrl.WindowState = System.Windows.Forms.FormWindowState.Normal;
ctrl.Visible = true;
}
this.LayoutMdi(MdiLayout.Cascade);
}
}
#endregion
Hope this helps someone
uploads/20061114_153426_MDISample_2.zip - uploads/20061114_153426_MDISample_2.zip uploads/20061114_153625_MDISample_2.zip - uploads/20061114_153625_MDISample_2.zip
|