Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. tabcontrol problem ? howto check if a different tab is clicked ?

tabcontrol problem ? howto check if a different tab is clicked ?

Scheduled Pinned Locked Moved C#
questionhelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.

    M M A 3 Replies Last reply
    0
    • L Lost User

      hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.

      M Offline
      M Offline
      Mairaaj Khan
      wrote on last edited by
      #2

      Mehmet Fatih Akbulut wrote:

      on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ?

      Yes. Write the following code in tabcontrol's Selected event. if(e.TabPageIndex == 0) MessageBox(e.TabPge.Name); else if(e.TabPageIndex == 1) MessageBox(e.TabPge.Name); Regards. _____________________________ Success is not something to wait for, its something to work for.

      1 Reply Last reply
      0
      • L Lost User

        hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.

        M Offline
        M Offline
        MCSD Gandalf
        wrote on last edited by
        #3

        I use the tabcontrol quite a bit in my application, and although you CAN use the index of the tab pages, using the text property gives you a bit more flexibility IMHO. For instance, so far my users have added 3 different tab pages, and deleted 2 of them, and changed the order of them 3 more times. By using the tabControlName.SelectedTab.Text property instead of the index, I don't have to change NEARLY as much code when things change, and my maintenance programmers will have a much easier time too. ;) HTH Gandalf

        1 Reply Last reply
        0
        • L Lost User

          hi all, on a tabcontrol, how do i know that if a different tab is clicked ? am i able to check this ? how ¿ let's say i have 3 tabpages. how can i show a messagebox with tabpage's.text when clicked ? thanks in advance, bye.

          A Offline
          A Offline
          Andrei Ungureanu
          wrote on last edited by
          #4

          hy, there is a very simple way to see which tab is selected. Use the SelectedIndex property. for example: if (tabControl1.SelectedIndex == 1) { MessageBox.Show("Tab1"); } you can also use this property to select a tab page: tabControl1.SelectedIndex = 2; If I'm not mistaking the first tab has the index 1 (or 0). Try it.

          M 1 Reply Last reply
          0
          • A Andrei Ungureanu

            hy, there is a very simple way to see which tab is selected. Use the SelectedIndex property. for example: if (tabControl1.SelectedIndex == 1) { MessageBox.Show("Tab1"); } you can also use this property to select a tab page: tabControl1.SelectedIndex = 2; If I'm not mistaking the first tab has the index 1 (or 0). Try it.

            M Offline
            M Offline
            Mairaaj Khan
            wrote on last edited by
            #5

            karkster wrote:

            If I'm not mistaking the first tab has the index 1 (or 0).

            index start from zero (0) for first item. _____________________________ Success is not something to wait for, its something to work for.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups