Barvna shema: Riviera
Trenutno dejavna stran: start » en » Documentation » Microsoft Access development tools » WKL Forms Object Library » WKL Forms Object Library how-to guides » How to: Use a layout on a navigation page

How to: Use a layout on a navigation page

Give a page in a navigation shell its own areas (such as a tree next to a list, with a detail strip below) by placing a second WklDockLayout on the page form, while the shell's layout arranges the bar and the page subform around it.

Requires WKL Forms Object Library 1.24 or later.

Solution overview

Each form gets its own layout: the shell's WklDockLayout arranges the WklNavBar and the page subform, and the page form's WklDockLayout (with FillSection, the default) arranges the page's areas inside the subform. Neither layout needs any code for the other:

  • The inner layout fills the subform. A form in a subform control uses the subform control's size as its window, so FillSection fills the page's visible Detail section. When the shell's layout widens the page (because the bar switched to the icon column or a splitter bar was dragged), the inner layout follows.
  • Swapping the page doesn't affect the shell. Setting the subform's SourceObject in Navigate replaces the page along with its layout. The shell's arrangement stays as it was, and a page that's shown again is rearranged from its design and its remembered state.
  • F6 moves through both levels. F6 and Shift+F6 step through the shell's areas; at the page subform, they continue through the page's areas and then return to the shell's next area, in a single cycle, regardless of which layout was created first.
  • The bar's shortcut works on the page. ToggleShortcut (Ctrl+B) also works when the focus is in an area of the inner layout, and the focus stays where it was.

Implementation

The shell form frmShell has a WklDockLayout with the bar navMain on the left and the page subform sfPage as the fill area. The page form frmOrdersPage has a WklDockLayout with a WklTreeList on the left, the orders subform as the fill area, and a detail subform at the bottom. Both layouts find their areas by position, so no code is needed beyond the navigation:

Private Sub navMain_Navigate(ByVal Key As String)
    Select Case Key
        Case "orders":    Me!sfPage.SourceObject = "Form.frmOrdersPage"
        Case "customers": Me!sfPage.SourceObject = "Form.frmCustomersPage"
    End Select
End Sub

When the same page form is shown in more than one shell, give the page's layout its own key so that each place remembers its own arrangement:

Private Sub Form_Open(Cancel As Integer)
    ' Page form, before its layout first arranges: the arrangement of this page in the orders shell.
    Me!Layout1.Object.LayoutKey = "frmOrdersPage.shell"
End Sub

Remarks

  • Tabbed documents and overlapping windows, in ACCDB and ACCDE files and in the Access Runtime, behave the same way: the inner layout fills the page subform's visible Detail section (except for the page form's record selector) and follows when the bar switches to the icon column. Switching to a page with a WklSplitter and back leaves the shell's arrangement unchanged and the inner layout as it was. F6 and Shift+F6 make a single cycle over the bar, the shell's bottom area, and the inner areas, even after the shell's layout has been rebuilt. Ctrl+B works when the focus is in an inner area or next to an inner splitter.
  • Anchor the page form's own controls as usual. The inner layout arranges only its own areas; a header with a title and commands stays in the page form's form header.
  • F6 alone doesn't need a layout on the page. Without an inner layout, F6 at the page subform moves the focus into the page, and the next F6 moves on to the shell's next area.
en/wiki/msaccess/comctl/how-to/use-a-layout-on-a-navigation-page.txt · Zadnja sprememba: uporabnika Wolfgang van der Stille