Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

How to select a specific Tabbed DockPanel.

When a tabbed panel is closed the focus always returns to the first (most left) tabbed panel.
Is it possible to return focus to the left of the panel which has been closed and freed.


  • 4 Comments sorted by Votes Date Added
  • edited October 2019 Posts: 0 Accepted Answer Vote Up0Vote Down
    Whole layout structure is encoded inside ZoneTree, which is exposed via Site.RootZone property. Each DockPanel also provides acees to its own zone via Panel.Zone property. 
    To achieve what you want, Panel's parent zone, which can be acessed via Panel.Zone.Parent can be used. This zone sohuld be of zkTabs kind, since the panel is a tabbed document. So, its SelectedPage property can be set to any of its child zones to activate another panel.
  • I have used this code in the DoClose event  of my editor which was intended to switch to the next tab down when current tab is closed.
    This gets called when I close the tab on which the editor is placed.

      dp := Parent as TLMDDockPanel;
      dz :=;
      i := dz.Panel.Zone.SelectedPage.Index;
      if i > -1 then
        dz.Panel.Zone.SelectedPage.Index := i -1;

    dp is returned correctly but and returns empty
      Action := caFree;

    Am I using this code in the wrong place or have I missed the point?

  • What you mean saying "empty"? nil? If yes, then its strange. 

    dp.Zone cannot be nil, because your panel is docked and will stay docked (even when invisible) until it destroyed. dp.Zone.Parent can be nil, in some cases (if panel is not a tabbed document, for example).

    Changing Index property (SelectedPage.Index := i -1;) is not correct. You move some zone to another location, but this does not change SelectedPage itself. 

    You need to do something like this:

      dp := Parent as TLMDDockPanel;
      dz :=;   // Panel's zone.
      i  := dz.Index;  
      tz := dz.Parent; // Tabs zone.
      if (tz <> nil) and (i > 0) then // If we are inside tabs and 
                                      // we are not the first child.
        prevz := tz[i - 1]; // Previous zone.
        tz.SelectedPage := prevz; // Change selected tab to prev zone.

  • edited October 2019 Posts: 58Vote Up0Vote Down
    That has worked beautifully, many thanks for your help, sorry I am a bit of a slow learner
Sign In or Register to comment.