I am trying to enable/disable the UltraWinTabbedMdi Manager to toggle between a tabbed manager and views that can be cascaded. Because I'm doing some off-the-wall code to create the forms, I don't have a handle on the control. So I iterate through the controls to find the tab group control in the example below. Note when I start, myForm.Controls.Count = 19.
foreach (Control ctrl in myForm.Controls){ if (ctrl is Infragistics.Win.UltraWinTabbedMdi.MdiTabGroupControl) { Infragistics.Win.UltraWinTabbedMdi.MdiTabGroupControl mtab = ((Infragistics.Win.UltraWinTabbedMdi.MdiTabGroupControl) ctrl ); mtab.TabGroup.Manager.Enabled = !mtab.TabGroup.Manager.Enabled; break; }}
After this runs, myForm.Controls.Count changes to 18. If I go through this iteration again, it never finds a mdiTabGroupControl, so I'm never able to set the Manager back to Enabled = true. So I guess the question is 1) why does disabling the Manager remove the tabgroup from the controls count, and 2) how can I get a handle on it again so I can re-enable the Manager?
Thanks.
It seems to make sense that the tab group control would be removed. If the tabbed mdi manager is no longer enabled, it doesn't need a tab group control to contain the child forms anymore. I would recommend caching a reference to the last disabled tabbed mdi manager when the iteration runs the first time and enable it instead of doing the normal iteration when your code runs the second time, like this (sorry if it doesn't compile, I'm just editing your code free-hand):
private UltraTabbedMdiManager lastDisabledMdiManager;
// ...
if (this.lastDisabledMdiManager != null){ this.lastDisabledMdiManager.Enabled = true; this.lastDisabledMdiManager = null; return;}
foreach (Control ctrl in myForm.Controls){ if (ctrl is Infragistics.Win.UltraWinTabbedMdi.MdiTabGroupControl) { Infragistics.Win.UltraWinTabbedMdi.MdiTabGroupControl mtab = ((Infragistics.Win.UltraWinTabbedMdi.MdiTabGroupControl) ctrl );
this.lastDisabledMdiManager = mtab.TabGroup.Manager; this.lastDisabledMdiManager.Enabled = false; break; }}