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
close icon

Finding the selected tab/control with multiple docked controls

I have 3 controls docked to the bottom of a form (show as tabbed) and 1 control docked on the left of the form. None of them are drag-able. For now i have drag and dropped them in the designer, set the enableDockingOnDockingManager to true, and dragged them to their location. I need to know which control is the currently selected tab on the bottom of the form. Is there a property or method on the DockingManager where i can find this out? Or an event when the selected tab changes? Thanks, Julie

9 Replies

JK Joy K George Syncfusion Team June 9, 2006 04:22 AM UTC

Hi Julie, The event DockControlActivated will fire each time when selected tab in DockTabControl changes .Please handle that event to get notification about selection. private void dockingManager1_DockControlActivated(object sender, Syncfusion.Windows.Forms.Tools.DockActivationChangedEventArgs arg){ if(dockingManager1.IsTabbed(arg.Control )) /*This method works from 4.2 onwards.If you are using 4.1. we are ready to provide equivalent code*/ { Console.WriteLine("Selected tab :"+ arg.Control.Name); } } If you want to get selected tab in other events such as Button click,you may follow the below method. private void button1_Click(object sender, System.EventArgs e) { DockHost dh=panel1.Parent as DockHost; //The panel1 should be a control present in the tab group. DockHostController dhc=dh.InternalController as DockHostController ; if(dhc.ParentController is DockTabController) { DockTabController dtc=dhc.ParentController as DockTabController ; if(dtc.TabControl.SelectedTab !=null) { Console.WriteLine("Selected control :"+dtc.TabControl.SelectedTab.Text); } } } Here attached a sample which demonstrate these methods. Please let me know ,if you need more assistance. Regards, Joy


JL Julie Levy June 12, 2006 05:27 PM UTC

Thanks. A couple of questions. 1. In the DockControlActivated Event, when i check the DockStyle of args.Control (to make sure it''s the bottom docked tab) it''s Fill instead of Bottom. I noticed the same behavior in the sample you sent. I need to be able to distinguish which tab because we may have multiple tabs on the left as well. 2. When getting the selected tab out of the DockHostController approach (in your click event), is there a way to get a reference to the control like in DockControlActivated, not just the name. I know i could do a FindControl method with the name, but before i do that just wanted to check if there''s a reference in there somewhere that i missed. Thanks again, Julie


JL Julie Levy June 12, 2006 05:55 PM UTC

One more question. The control i am docking is a user control which contains a GridControl. I noticed the scrolling isn''t happening correctly. There is no horizontal scroll bar and the vertical scroll bar appears, but is cut off at the bottom. Therefore, the entire control is not visible. You can''t scroll all the way down. Before i try and reproduce this for you in a sample, i thought i would ask what is the proper way to handle scrolling of user controls with the Docking Manager. Thanks, Julie


JL Julie Levy June 12, 2006 06:28 PM UTC

sorry, this is an issue with the minimum size of my control. The horizontal scrollbar isn''t visible because it''s been resized smaller than the control. I''m not sure that it has anything to do with the docking manager. What''s the best approach to preventing the user from resizing the docked control beyond the minimum size? Is there something in the dockingmanager that helps manage this?


JK Joy K George Syncfusion Team June 13, 2006 05:14 AM UTC

Hi Julie, Thanks for your updates. 1.I am looking into this .You will get an update soon. 2.You may change the click event as follows. private void button1_Click(object sender, System.EventArgs e){ DockHost dh=panel1.Parent as DockHost; //The panel1 is a control present in the tab group DockHostController dhc=dh.InternalController as DockHostController ; if(dhc.ParentController is DockTabController) { DockTabController dtc=dhc.ParentController as DockTabController ; if(dtc.TabControl.SelectedTab !=null) { DockTabPage dtp=dtc.TabControl.SelectedTab as DockTabPage; Console.WriteLine("Selected control :"+dtp.dhcClient.HostControl.Controls[0].ToString()); } } } 3.You could set the Minimum size of docked control using the following method. dockingManager1.SetControlMinimumSize(panel1 ,new Size(100,100)); Please let me know,If you have any queries regarding this. Regards, Joy



JL Julie Levy June 13, 2006 04:56 PM UTC

Thanks for you response. Regarding issue number 1, are you saying that the the DockStyle of args.Control in DockControlActivated is wrong (Fill instead of Bottom) and that i shouldn''t use it?


JK Joy K George Syncfusion Team June 14, 2006 05:07 AM UTC

Hi Julie, The DockingStyle of args.Control in DockControlActivated gives you the DockingStyle of that particular control.But in this case that control is in DockTabControl.So you need to get the DockingStyle of coresponding docktabcontrol. If the control is not tabbed with any other controls,you can get the dockingstyle of arg.Control directly using the method dockingManager1.GetDockStyle(arg.Control). Note: We are using a wrapper control called DockHost to hold the controls after enabling docking.So if you access Control.Dock property it will always return Fill. Please let me know ,if this helped you. Regards, Joy


JL Julie Levy June 14, 2006 04:22 PM UTC

This definitely helped a lot. Thanks! Julie

Loader.
Live Chat Icon For mobile
Up arrow icon