We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Question about MDI Tabs....

I am trying to learn how to use the Syncfusion MDI Tabs and have a question. I have a certain child form that when open needs to be listed first all the time. This form usually exists on load, but the user can close it. If the user ever decides to open this form up, it needs to be listed as the first form in the tabs. How do you do this?? Thank you for your help. Javier

7 Replies

AD Administrator Syncfusion Team September 13, 2004 02:01 PM

I think I figure out how to do this. The code I used is Dim x As Object Dim i As Integer Me.mFrmProjects = New FrmProjects Me.AddNewForm(Me.mFrmProjects, "Projects") i = Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabCount - 1 While i > 0 x = Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i) Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i) = Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i - 1) Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i - 1) = x i -= 1 End While Not sure if this is the best way, but its the only solution i could come up with. I did find an issue tho...and i''m not sure if its related to this this code. Randomly, the WinForms Close (the "X" on the mdicontainer) does not close the program. I''m not sure what it causing it to stop working. To duplicate I basicly close tabs and open them and eventually it stops working. This happens on both my laptop and my main computer. Any idea as to why this is happening? Thank you, Javier


KP Khoi Phan September 14, 2004 06:25 PM

To illustrate the problem Javier described earlier, please see the attached sample (this is Syncfusion sample by the way). I only remove the lines that add 4 child forms in the MainForm_Load(). The steps to reproduce the problem: - Run the application, click File/New/Document1 twice. - Click tab "DocumentOne 1" - Click the X (close button) of the TabbedMDIManager twice to close those 2 tabs. - Finally, try to close the application by clicking the X (close button) of the MDI form or the Exit menu item. The form will not go away. Suggested solution: You can fix this problem by adding a line: - Me.Dispose in the Closing event of the MDI form. > >I think I figure out how to do this. The code I used is > > Dim x As Object > Dim i As Integer > Me.mFrmProjects = New FrmProjects > Me.AddNewForm(Me.mFrmProjects, "Projects") > i = Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabCount - 1 > While i > 0 > x = Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i) > Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i) = Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i - 1) > Me.mTabMDI.TabGroupHosts(0).MDITabPanel.TabPages(i - 1) = x > i -= 1 > End While > >Not sure if this is the best way, but its the only solution i could come up with. > >I did find an issue tho...and i''m not sure if its related to this this code. > >Randomly, the WinForms Close (the "X" on the mdicontainer) does not close the program. I''m not sure what it causing it to stop working. To duplicate I basicly close tabs and open them and eventually it stops working. This happens on both my laptop and my main computer. Any idea as to why this is happening? > > >Thank you, > > >Javier >


AD Administrator Syncfusion Team September 14, 2004 06:37 PM

Sorry, here''s the sample. I just removed these 4 lines in method MainForm_Load of the MainForm.cs this.addDoc1_Click(this, EventArgs.Empty); this.addDoc1_Click(this, EventArgs.Empty); this.addDoc1_Click(this, EventArgs.Empty); this.addDoc1_Click(this, EventArgs.Empty); TabbedMDI_Bug_8955.zip


AD Administrator Syncfusion Team September 15, 2004 12:29 PM

Hi Khoi Phan, Thanks for the modified sample. I have tested this as per your directions in v2.1.0.9 and the sample worked fine. After closing the tabbed MDI child forms, I was able to close the main form by clicking on it "X" close button, without having to use the workaround of handling the Closing event and calling a Dispose on itself. Are you using on earlier version of Essential Suite ? If so, could you please upgrade to v2.1.0.9 and see if you can recreate this problem in our latest release? Hi Javier, I have attached a test sample here created as per your requirements in your first update. Please note the TabbedMDIManager''s TabControl, host form''s Load and the BarItem''s Click event handlers. TabControlAdv tabcontrol; TabPageAdv tabpage; private void TabbedMDI_TabControlAdded(object sender, TabbedMDITabControlEventArgs args) { tabcontrol = args.TabControl; } private void Form1_Load(object sender, System.EventArgs e) { this.tabpage = this.tabcontrol.TabPages[0]; this.tabcontrol.SelectedTab = this.tabpage; this.tabcontrol.TabPages.MoveTabPage(this.tabcontrol.TabPages.IndexOf(tabpage), 0); } private void barItem1_Click(object sender, System.EventArgs e) { f1 = new Form2(); f1.Name = "Child1"; f1.Text = "Child1"; f1.SetLabel("Child1"); f1.MdiParent = this; f1.Show(); this.tabcontrol.TabPages.MoveTabPage(this.tabcontrol.TabPages.Count-1, 0); } Please let me know if this meets your requirements. Thanks for choosing Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.


AD Administrator Syncfusion Team September 15, 2004 01:20 PM

Thanks for the code. I was able to get the bug again in your code, as well as in Khoi code (following the directions he gives). I am using the 2.1.0.9 version. I am using VS.NET 2003 with Framework 1.1. Not sure if this might be related or not, but it seems that the bug occurs more often (or easier to reproduce) if you start the application with no child forms open by default. Javier


KP Khoi Phan September 16, 2004 03:18 PM

I modified the sample you gave Javier a little bit to reproduce the problem. Steps to reproduce the problem: - Run the app - Click on ''New child'' 3 times (to create 3 tabs). - Click on ''Child 2'' tab, then ''Child 1'' tab (the order matters). - Now click on the close button of the MDI tab manager 3 times (to close all 3 tabs). - Finally try to close the MDI main form. The problem appears when you start your MDI with zero child form. After you create the forms, try to click each tab once starting with the second highest one. For example, if you create 4 tabs (tab 0, tab1, tab2, tab3) you must click tab3, then tab2, then tab1 and finally tab0. After that, just click the X button 4 times to close them all. Now the MDI main form cannot be closed. >Hi Khoi Phan, > >Thanks for the modified sample. I have tested this as per your directions in v2.1.0.9 and the sample worked fine. After closing the tabbed MDI child forms, I was able to close the main form by clicking on it "X" close button, without having to use the workaround of handling the Closing event and calling a Dispose on itself. Are you using on earlier version of Essential Suite ? If so, could you please upgrade to v2.1.0.9 and see if you can recreate this problem in our latest release? > > >Hi Javier, > >I have attached a test sample here created as per your requirements in your first update. Please note the TabbedMDIManager''s TabControl, host form''s Load and the BarItem''s Click event handlers. > >TabControlAdv tabcontrol; > TabPageAdv tabpage; > > private void TabbedMDI_TabControlAdded(object sender, TabbedMDITabControlEventArgs args) > { > tabcontrol = args.TabControl; > } > >private void Form1_Load(object sender, System.EventArgs e) > { > this.tabpage = this.tabcontrol.TabPages[0]; > this.tabcontrol.SelectedTab = this.tabpage; > this.tabcontrol.TabPages.MoveTabPage(this.tabcontrol.TabPages.IndexOf(tabpage), 0); > } > > private void barItem1_Click(object sender, System.EventArgs e) > { > f1 = new Form2(); > f1.Name = "Child1"; > f1.Text = "Child1"; > f1.SetLabel("Child1"); > f1.MdiParent = this; > f1.Show(); > > this.tabcontrol.TabPages.MoveTabPage(this.tabcontrol.TabPages.Count-1, 0); > } > >Please let me know if this meets your requirements. Thanks for choosing Syncfusion products. > >Regards, >Guru Patwal >Syncfusion, Inc. tabbedmdi_taborder_2019.zip


AD Administrator Syncfusion Team September 19, 2004 02:20 PM

Hi Khoi Phan/Javier, Thanks for the update and the test sample. Once again, I was unable to see this issue using our latest build. Please create an incident in Direct-Trac in this regard, and I will update you with more information there. We appreciate your cooperation, and thanks for your continued interest in Syncfusion products. Regards, Guru Patwal Syncfusion, Inc.

Loader.
Live Chat Icon For mobile
Up arrow icon