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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Change focus of the flap automatically when clicking

Thread ID:

Created:

Updated:

Platform:

Replies:

144787 May 22,2019 01:28 PM UTC May 24,2019 06:44 AM UTC WinForms 3
loading
Tags: TabbedMDIManager
Julio Cezar Mendonca
Asked On May 22, 2019 01:28 PM UTC

Good Morning,

I am not able to change the focus of the tab, created by MDI, when selecting the corresponding menu / option, I did not find or I was able to create an event for this.

In the system I have a menu, which each when clicking creates an MDI tab (which is created only once, avoiding duplicate tabs).

When I click on a menu, where the created tab already exists, I would like the focus to go directly to that tab.

Below I will replicate my code, and attached an image to better exemplify it.

        private void MenuEmpresasClick(object sender, EventArgs e)
        {
            this.IsMdiContainer = true;
            this.tabbedMDIManager1.AttachToMdiContainer(this);
            this.tabbedMDIManager1.TabStyle = typeof(Syncfusion.Windows.Forms.Tools.TabRendererDockingWhidbey);

            MetroForm2 form = new MetroForm2 { Text = "Empresas" };

            var childrenFind = this.tabbedMDIManager1.MdiChildren.Where(f => f.Text == form.Text).Any();

            if (!childrenFind)
                form.MdiParent = this;
            else
               // focus on the flap that is already open


        }

Thank you,

Júlio C. Mendonça

Attachment: Question_WinForms_180787b9.rar

Jagadeesan Pichaimuthu [Syncfusion]
Replied On May 23, 2019 01:11 PM UTC

Hi Julio 
  
Thanks for your contacting Syncfusion support. 
  
We have checked your query “Need to change focus to the corresponding tab when click the menu item”. We have hosted the child of TabbedMDIManager inside the TabControlAdv.  We can achieve your requirement using TabControlAdv with help of the TabControlAdded event of TabbedMdIManager. We have prepared the sample, In which we have set the selected tab(Tab which created already) when you click the menu item. Please find the code Snippet and Sample for the same. 
  
Code Snippet: 
  
  this.tabbedMDIManager1.TabControlAdded += TabbedMDIManager1_TabControlAdded; 
            Form2 form = new Form2 { Text = "Titulos" }; 
            form.BackColor = Color.Red; 
            form.MdiParent = this; 
            form.Show(); 
            this.mainFrameBarManager1.Style = VisualStyle.Office2016Colorful; 
            this.barItem1.Click += ParentBarItem1_Click; 
        } 
  
        private void TabbedMDIManager1_TabControlAdded(object sender, TabbedMDITabControlEventArgs args) 
        { 
            tabcontrol = args.TabControl; 
        } 
  
        private void ParentBarItem1_Click(object sender, System.EventArgs e) 
        { 
            MetroForm form = new MetroForm { Text = "Empresas" }; 
  
            var childrenFind = this.tabbedMDIManager1.MdiChildren.Where(f => f.Text == form.Text).Any(); 
  
            if (!childrenFind) 
            { 
                form.MdiParent = this; 
                form.Show(); 
            } 
            else 
            { 
                if(tabcontrol != null) 
                { 
                    foreach(TabPageAdv page in tabcontrol.TabPages) 
                    { 
                        if(page.Text== form.Text) 
                        { 
                            // focus on the flap that is already open 
                            tabcontrol.SelectedTab = page; 
                            break; 
                        } 
                    } 
                 
                } 
               
            } 
  
        } 
    } 
} 
  
  
Please try this above solution and let us know if it is helpful. If we misunderstood your requirement, please provide more information regarding the requirement. It would be more helpful to proceed further. 
  
Regards, 
Jagadeesan

Julio Cezar Mendonca
Replied On May 23, 2019 04:00 PM UTC

Good afternoon

Got it. Thanks for the help and clarification.

Júlio C. Mendonça

Jagadeesan Pichaimuthu [Syncfusion]
Replied On May 24, 2019 06:44 AM UTC

Hi Julio, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Jagadeesan 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon