Programatically 'Select' a Krypton Page

Topics related to the Krypton Docking.

Moderators: Phil Wright, Chris Porter

Programatically 'Select' a Krypton Page

Postby vw_gpt » Thu Nov 04, 2010 5:35 pm

Hi,

I have a 3 Krypton Pages stacked together .. By default, the first page will appear on top. My question is, how do I programatically select a page, so that it appear on top of the other? (i.e. the same if we 'click' on the tab, but how do I do it in the code?)
Any help would be much appreciated.

Thank you.
VW.
vw_gpt
 
Posts: 1
Joined: Thu Nov 04, 2010 4:07 pm

Re: Programatically 'Select' a Krypton Page

Postby namibian » Thu Jan 20, 2011 3:54 am

I have the same issue. Any resolution/help?
namibian
 
Posts: 3
Joined: Wed Dec 22, 2010 1:07 am

Re: Programatically 'Select' a Krypton Page

Postby Phil Wright » Thu Jan 20, 2011 10:13 pm

At the moment there is no code to do this for you. You would need to update the SelectedPage property of the Navigator that contains the page in question.
Phil Wright
Site Admin
 
Posts: 2720
Joined: Thu Apr 13, 2006 2:55 pm
Location: Melbourne, Australia

Re: Programatically 'Select' a Krypton Page

Postby johnfermor » Mon Feb 28, 2011 12:23 am

Hi

I wrote this in VB.NET and it works great for my needs..

To call it simply pass the name of the KryptonNavigator and a ";" delimitted string of page titles to display. You can optionally specify the default (selected) page.

Example:
Code: Select all
ShowNavigatorTabPages(myNavigator; "Main;Reports;Finance;Admin;Assets", "Finance")

This example displays the Main, Reports, Finance, Admin & Assets pages and selects the Finance page.

To display only a single page (and hide all others) just specify the Navigator and the Page title to display

Example:
Code: Select all
ShowNavigatorTabPages(myNavigator; "Reports")


It was a quick 'n' dirty (but reliable) effort so no laughing :D . It's fairly basic and can't cope with page reordering, missing tabs, etc. But it will display the tabpages you specify, hide all others and optionally select a "default" page.

Hope it helps someone out there as this had me stumped for a while!

John


Code: Select all
    Sub ShowNavigatorTabPages(ByVal myKryptonNavigator As KryptonNavigator, ByVal myPageTitlesToShow As String, Optional ByVal myDefaultPage As String = "")

            ' ==============================================================================================
            ' ShowNavigatorTabPages. V1.0.0 - May 2008.
            ' Shows (and Hides) Tabs on the KryptonNavigator & optionally selects a Page
            ' ----------------------------------------------------------------------------------------------
            ' In:   myKryptonNavigator   Krypton Navigator containing the Tabs to Display
            '       myPageTitlesToShow   ";" Delimitted string containing the Titles of the Tab Pages you
            '                            wish to view - all others are hidden by default
            '       myDefaultPage        Title of the Krypton Tab Page you wish to SELECT by default (Optional)
            ' ==============================================================================================

            ' ****************************************
            ' ** Get a List of the Pages to Display **
            ' ****************************************

            Dim arrPage As String() = Strings.Split(myPageTitlesToShow, ";")

            With myKryptonNavigator

                ' *********************************************************************************
                ' ** Ensure all NavPages are hidden EXCEPT those supplied in the delimitted list **
                ' *********************************************************************************

                For Each KryptonPage In .Pages

                    Dim blnVisible As Boolean = False

                    For intIndex = 0 To UBound(arrPage)

                        If LCase(arrPage(intIndex)) = LCase(KryptonPage.Text) Then

                            blnVisible = True

                            Exit For

                        End If

                    Next

                    KryptonPage.Visible = blnVisible

                Next

                ' ************************************************************************************
                ' ** Get the Default Tab Page (if supplied) or assume the first page is the default **
                ' ************************************************************************************

                If myDefaultPage = "" Then myDefaultPage = arrPage(0)

                For Each KryptonPage In .Pages

                    If LCase(KryptonPage.Text) = LCase(myDefaultPage) Then

                        .SelectedPage = KryptonPage

                        Exit For

                    End If
                Next

                ' **************************************************
                ' ** If viewing single tab, lose the Tab Headers! **
                ' **************************************************

                .NavigatorMode = IIf(UBound(arrPage) > 0, NavigatorMode.BarTabGroup, NavigatorMode.Group)

                Application.DoEvents()

            End With

            ' **************
            ' ** Clean Up **
            ' **************

            arrPage = Nothing

        End Sub ' ShowNavigatorTabPages



Attached File:VB.NET 2008
Attachments
NavigatorTest.zip
Navigator Test
(53.63 KiB) Downloaded 26 times
johnfermor
 
Posts: 101
Joined: Fri Oct 05, 2007 1:32 am
Location: Great Britain UK

Re: Programatically 'Select' a Krypton Page

Postby bjn4645 » Tue Dec 20, 2011 11:08 pm

Hey johnfermor,

Thanx for the code and the file. Much appreciated. So awesome of you to share it.

Thanx again,
Bojan
Online Researcher
Working with heeltastic
bjn4645
 
Posts: 1
Joined: Tue Dec 20, 2011 11:00 pm


Return to Krypton Docking

Who is online

Users browsing this forum: No registered users and 0 guests