C!DockingTabPage.TabClick event does not exists

Posted by: chris.bertsch on 3 May 2019, 12:48 am EST

    • Post Options:
    • Link

    Posted 3 May 2019, 12:48 am EST

    In the documentation, it shows there should be a TabClick event for the DockingTabPage, but it does not exist. I’m trying to find out which DockingTabPage a user clicked on. I cannot use the SelectedIndexChange* events because as soon as a user tears a tab off and docks it somewhere else, it’s not part of the original DockingTab control anymore.

    http://helpcentral.componentone.com/nethelp/c1command/C1.Win.C1Command.4~C1.Win.C1Command.C1DockingTabPage_members.html

  • Posted 5 May 2019, 8:53 pm EST

    Hello Chris,

    As the documentations mentions, the TabClick event does exist for C1DockingTabPage and also, its working properly.

    I used the latest ComponentOne version: 4.0.20191.363 at my end. What version are you using?

    Thanks,

    Ruchir

  • Posted 13 May 2019, 1:45 am EST - Updated 3 October 2022, 4:09 pm EST

    I’m on version 4.0.20153.112. Attached is a screen shot of the proerties for the dtp. it sorted alphabetically, and you can see, not TabClick event. Nothing even comes up when I try to manually create the event handler.

  • Posted 13 May 2019, 5:28 pm EST

    Hello,

    The event was added to the API from 2016V1.

    You can refer the “New Features” topic under “Menus and Toolbars for Winforms” under release notes:

    http://help.grapecity.com/componentone/NetHelp/WinForms_ReleaseHistory/webframe.html#2016%20v1.5.html

    This is the reason it does not exist in the API in the 2015 V3 version you use.

    Regards,

    Esha

  • Posted 21 May 2019, 5:42 am EST

    Is there a work around you know of?

  • Posted 21 May 2019, 3:54 pm EST

    Hi Chris,

    To find out which DockingTabPage a user clicked on using assemblies of version prior to *.20161.145, you may handle C1DockingTab’s MouseClick event in the following way:

    private void c1DockingTab1_MouseClick(object sender, MouseEventArgs e)
    {
           if (e.Button == System.Windows.Forms.MouseButtons.Left)
           {
               for (int pg = 0; pg < c1DockingTab1.TabPages.Count; pg++)
               {
                   if (c1DockingTab1.TabPages[pg].TabBounds.Contains(e.Location) == true)
                  {
                       System.Diagnostics.Debug.WriteLine($"DockingTabPage clicked: {c1DockingTab1.TabPages[pg].Name}");
                  }
              }
          }
    }
    ```Also, attached is a sample application for reference.
    This would hopefully help meet your requirement acting as an alternative to TabClick event.
    
    Best wishes,
    
    Ruchir
    [zip filename="TabClick_TabPage.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-a2a02b2a-5d69-4654-aa8c-8a553437e69a.zip[/zip]
  • Posted 22 May 2019, 12:44 am EST

    That’s getting me closer! However, as soon as you tear a tab page off the docking tab, it doesn’t register that tab when clicked. Is there an event that is called after a tab page is tore off a docking tab where I could assign a modified version of that click event?

  • Posted 22 May 2019, 4:44 pm EST

    Hello,

    When we tear off a page from a dockingtab, a new DockingTab is created and added to C1CommandDock’s Control collection. Then the teared off is removed from parent DockingTab’s TabPages collection and added to the new DockingTab’s TabPages collection.

    To take care of such scenario, you should handle C1CommandDock’s ControlAdded event and inside add a handler to its MouseClick event as follows:

    private void Form1_Load(object sender, EventArgs e)
    {
        c1CommandDock1.ControlAdded += C1CommandDock1_ControlAdded;
    }
    private void C1CommandDock1_ControlAdded(object sender, ControlEventArgs e)
    {
        if(e.Control.GetType()==typeof(C1.Win.C1Command.C1DockingTab))
        {
            var newTab = e.Control as C1.Win.C1Command.C1DockingTab;
            if(newTab.HasChildren)
            {
                newTab.MouseClick += c1DockingTab1_MouseClick;
            }
        }
    }
    private void c1DockingTab1_MouseClick(object sender, MouseEventArgs e)
    {
        var dockTab = sender as C1.Win.C1Command.C1DockingTab;
        if (e.Button == System.Windows.Forms.MouseButtons.Left)
        {
            for (int pg = 0; pg < dockTab.TabPages.Count; pg++)
            {
                if (dockTab.TabPages[pg].TabBounds.Contains(e.Location) == true)
                {
                    System.Diagnostics.Debug.WriteLine($"DockingTabPage clicked: {dockTab.TabPages[pg].Name}");
                }
            }
        }
    }
    
    ```Also, I've modified the application and attached here for your reference.
    Let me know, if you find any other scenarios where you want to detect tab click to work.
    
    Best Regards,
    Ruchir
    [zip filename="TabClick_TabPageModified.zip"]https://gccontent.blob.core.windows.net/forum-uploads/file-3fb95be0-8c73-4600-b5be-9425ad9375a1.zip[/zip]
  • Posted 3 June 2019, 7:02 am EST

    I had to add an additional event for when the user tore the tabpage off and did not move it within the dockingtabpage it came from.

    
    private void dtpProductionReports_ControlAdded(object sender, ControlEventArgs e)
            {
                if (e.Control.GetType() != typeof(C1CommandDock)) return;
                C1CommandDock cd = e.Control as C1CommandDock;
    
                cd.ControlAdded += cdReports_ControlAdded;
            }
    
    
  • Posted 3 June 2019, 8:40 pm EST

    Thank you Chris for sharing the extended solution here. It’d help other community members with same requirement.

    ~Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels