TabPage Changing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ray well

    #1

    TabPage Changing

    i want a user to be able to change tab pages thru the keyboard, i tried
    entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the
    user can change pages by type ALT 1, ALT 2, on the keyboard.

    but the text showing up in the tab is '&1 Names' instead of the '1' being
    underlined, and being able to be accessed thru the keyboard.

    how can i get a user to be able to change from TabPage to TabPage thru the
    keyboard? i find it hard to beleive it can't be done.

    thanks,

    ray


  • rowe_newsgroups

    #2
    Re: TabPage Changing

    On Jul 12, 12:28 pm, "ray well" <nos...@nospam. comwrote:
    i want a user to be able to change tab pages thru the keyboard, i tried
    entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the
    user can change pages by type ALT 1, ALT 2, on the keyboard.
    >
    but the text showing up in the tab is '&1 Names' instead of the '1' being
    underlined, and being able to be accessed thru the keyboard.
    >
    how can i get a user to be able to change from TabPage to TabPage thru the
    keyboard? i find it hard to beleive it can't be done.
    >
    thanks,
    >
    ray
    Ctrl+PageDown and Ctrl+PageUp are the standard Window's commands for
    this.

    Also, you could moniter the keypress/keyup/keydown events for "alt 1"
    and then change the tabpage via code.

    Thanks,

    Seth Rowe

    Comment

    • ray well

      #3
      Re: TabPage Changing

      >>Ctrl+PageDo wn and Ctrl+PageUp are the standard Window's commands for
      this.<<

      seth,

      thanks your reply.

      but if u have a whole bunch of tab pages, it becomes a pain to have to go
      thru all of them instead of going to the one u need directly.

      ray


      Comment

      • Mick Doherty

        #4
        Re: TabPage Changing

        The standard Windows.Forms.T abControl does not support this feature.

        You can ownerdraw the TabControl to draw the tab text with the mnemonic and
        then catch the mnemonics and change tabpage as appropriate.

        You will find basic examples of this on my site:


        If you don't want to draw the tabs yourself (a lot of work especially with
        Visual Styles), then you may like to use TabControlEx instead. This has
        mnemonic support built in and also includes several other frequently
        requested features.
        Download custom Windows Forms controls and components for .NET applications. TabControlEx, MenuSkinner, and more.


        --
        Mick Doherty
        Dotnetrix offers Nothing. Standard and Premium versions available.



        "ray well" <nospam@nospam. comwrote in message
        news:OQVquKKxHH A.424@TK2MSFTNG P06.phx.gbl...
        >i want a user to be able to change tab pages thru the keyboard, i tried
        >entering the TabPage.text as '&1 Names', "&2 Addresses', etc., so that the
        >user can change pages by type ALT 1, ALT 2, on the keyboard.
        >
        but the text showing up in the tab is '&1 Names' instead of the '1' being
        underlined, and being able to be accessed thru the keyboard.
        >
        how can i get a user to be able to change from TabPage to TabPage thru the
        keyboard? i find it hard to beleive it can't be done.
        >
        thanks,
        >
        ray
        >
        >

        Comment

        • rowe_newsgroups

          #5
          Re: TabPage Changing

          On Jul 12, 2:20 pm, "ray well" <nos...@nospam. comwrote:
          >Ctrl+PageDow n and Ctrl+PageUp are the standard Window's commands for
          >
          this.<<
          >
          seth,
          >
          thanks your reply.
          >
          but if u have a whole bunch of tab pages, it becomes a pain to have to go
          thru all of them instead of going to the one u need directly.
          >
          ray
          Like I said, you can watch the keyevents and then code in the
          functionality for switching to a certain tab.

          Thanks,

          Seth Rowe

          Comment

          • Cor Ligthert [MVP]

            #6
            Re: TabPage Changing

            Rowe,

            Do you have an idea how that would be done?

            Cor

            "ray well" <nospam@nospam. comschreef in bericht
            news:eYu0hGLxHH A.1484@TK2MSFTN GP06.phx.gbl...
            >>>Ctrl+PageDow n and Ctrl+PageUp are the standard Window's commands for
            this.<<
            >
            seth,
            >
            thanks your reply.
            >
            but if u have a whole bunch of tab pages, it becomes a pain to have to go
            thru all of them instead of going to the one u need directly.
            >
            ray
            >
            >

            Comment

            • rowe_newsgroups

              #7
              Re: TabPage Changing

              On Jul 13, 12:38 am, "Cor Ligthert [MVP]" <notmyfirstn... @planet.nl>
              wrote:
              Rowe,
              >
              Do you have an idea how that would be done?
              >
              Cor
              >
              "ray well" <nos...@nospam. comschreef in berichtnews:eYu 0hGLxHHA.1484@T K2MSFTNGP06.phx .gbl...
              >
              >>Ctrl+PageDo wn and Ctrl+PageUp are the standard Window's commands for
              this.<<
              >
              seth,
              >
              thanks your reply.
              >
              but if u have a whole bunch of tab pages, it becomes a pain to have to go
              thru all of them instead of going to the one u need directly.
              >
              ray
              Do you have an idea how that would be done?
              Of course I do!

              Just start a new form and replace it's code behind with the below and
              run the form. Presses Alt+1 will select the first page, Alt+2 selects
              the second and Alt+3 will select the third tabpage. I would recommend
              the OP inherit TabPage and add a new property for the keycode instead
              of using Tag - but for sake of brevity I used Tag.

              //////////////
              Public Class Form1

              Dim tabControl As New TabControl()

              Public Sub New()
              InitializeCompo nent()

              Me.KeyPreview = True

              TabControl.Name = "tabControl 1"

              For i As Integer = 1 To 3
              Dim tabPage As New TabPage(String. Format("TabPage {0}",
              i.ToString()))
              '// Store the target keycode in the Tag property
              '// A value of "D2, Alt" will select the control
              '// when the user presses Alt+2
              tabPage.Tag = String.Format(" D{0}, Alt", i.ToString())
              TabControl.TabP ages.Add(tabPag e)
              Next

              Me.Controls.Add (TabControl)
              TabControl.Loca tion = New Point(30, 30)

              End Sub

              Private Sub Form1_KeyUp(ByV al sender As System.Object, ByVal e As
              System.Windows. Forms.KeyEventA rgs) Handles MyBase.KeyUp
              If e.Alt Then
              For Each tabPage As TabPage In tabControl.TabP ages
              If tabPage.Tag.ToS tring() = e.KeyData.ToStr ing() Then
              tabControl.Sele ctedTab = tabPage
              Exit For
              End If
              Next
              End If
              End Sub

              End Class
              ////////////////////

              Thanks,

              Seth Rowe

              Comment

              Working...