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 events

TabControl events

Scheduled Pinned Locked Moved C#
databasehelptutorialquestion
10 Posts 3 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.
  • N Offline
    N Offline
    nlowdon
    wrote on last edited by
    #1

    Good evening all, I have a form with a number of controls on it. In particular - some buttons and a 'TabControl' In the form designer, when i double click on a button, i can code an event to fire, like below,

    private void button1_Click(object sender, EventArgs e)
    {
    //some code
    }

    I would like t be able to do the same when the user clicks on one of the tabs of my TabControl, however i can seem to find a way to trigger an event like i do with a button. For example - if i double cick on the tab in the designer view - nothing happens. Can anyone help ? Regards Neil

    realJSOPR L 3 Replies Last reply
    0
    • N nlowdon

      Good evening all, I have a form with a number of controls on it. In particular - some buttons and a 'TabControl' In the form designer, when i double click on a button, i can code an event to fire, like below,

      private void button1_Click(object sender, EventArgs e)
      {
      //some code
      }

      I would like t be able to do the same when the user clicks on one of the tabs of my TabControl, however i can seem to find a way to trigger an event like i do with a button. For example - if i double cick on the tab in the designer view - nothing happens. Can anyone help ? Regards Neil

      realJSOPR Offline
      realJSOPR Offline
      realJSOP
      wrote on last edited by
      #2

      Check out the events in the properties window for the control. You have click, doubleclick, etc.

      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
      -----
      "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

      1 Reply Last reply
      0
      • N nlowdon

        Good evening all, I have a form with a number of controls on it. In particular - some buttons and a 'TabControl' In the form designer, when i double click on a button, i can code an event to fire, like below,

        private void button1_Click(object sender, EventArgs e)
        {
        //some code
        }

        I would like t be able to do the same when the user clicks on one of the tabs of my TabControl, however i can seem to find a way to trigger an event like i do with a button. For example - if i double cick on the tab in the designer view - nothing happens. Can anyone help ? Regards Neil

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        Hi, TabControl.SelectedIndexChanged is the right event for you; you may want to include a switch in its handler if you need to run different code snippets for different tab pages. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Fixturized forever. :confused:


        N 1 Reply Last reply
        0
        • N nlowdon

          Good evening all, I have a form with a number of controls on it. In particular - some buttons and a 'TabControl' In the form designer, when i double click on a button, i can code an event to fire, like below,

          private void button1_Click(object sender, EventArgs e)
          {
          //some code
          }

          I would like t be able to do the same when the user clicks on one of the tabs of my TabControl, however i can seem to find a way to trigger an event like i do with a button. For example - if i double cick on the tab in the designer view - nothing happens. Can anyone help ? Regards Neil

          realJSOPR Offline
          realJSOPR Offline
          realJSOP
          wrote on last edited by
          #4

          Has anyone suggested to you yet that you should put a UserControl on each tab page that contains that tab page's controls so you can have discreet access to all the controls on a given page?

          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
          -----
          "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

          1 Reply Last reply
          0
          • L Luc Pattyn

            Hi, TabControl.SelectedIndexChanged is the right event for you; you may want to include a switch in its handler if you need to run different code snippets for different tab pages. :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            Fixturized forever. :confused:


            N Offline
            N Offline
            nlowdon
            wrote on last edited by
            #5

            Thank you Luc, So can you please give me some guidance as to how i would then use this to make some.....labels or checkboxes appear for instance ? I have trid a few things but it seems quit a dfficult control to use. Thanks Neil

            L 1 Reply Last reply
            0
            • N nlowdon

              Thank you Luc, So can you please give me some guidance as to how i would then use this to make some.....labels or checkboxes appear for instance ? I have trid a few things but it seems quit a dfficult control to use. Thanks Neil

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              As John pointed out, the easiest way to handle a TabControl in Visual Designer is to create one UserControl per tabpage; i.e. first create the UserControls you want, then create a TabControl on your form and instantiate the UserControls on the individual pages. An alternative, not that popular though, is to create the Controls by run-time code. :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              Fixturized forever. :confused:


              N 1 Reply Last reply
              0
              • L Luc Pattyn

                As John pointed out, the easiest way to handle a TabControl in Visual Designer is to create one UserControl per tabpage; i.e. first create the UserControls you want, then create a TabControl on your form and instantiate the UserControls on the individual pages. An alternative, not that popular though, is to create the Controls by run-time code. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                Fixturized forever. :confused:


                N Offline
                N Offline
                nlowdon
                wrote on last edited by
                #7

                unfortunatley i'm completely new to programming so all that means very little to me. Its my first time trying a tabControl, i have created & tested all my buttons to go on it, i just needed other things to appear on the form when user chose the varius tabs on the form. I'm kind of thinking i've bitten off more than i can chew ? :confused: I'll have a look for infon on 'UserControls' and see what i can find. Many thanks Neil

                L 1 Reply Last reply
                0
                • N nlowdon

                  unfortunatley i'm completely new to programming so all that means very little to me. Its my first time trying a tabControl, i have created & tested all my buttons to go on it, i just needed other things to appear on the form when user chose the varius tabs on the form. I'm kind of thinking i've bitten off more than i can chew ? :confused: I'll have a look for infon on 'UserControls' and see what i can find. Many thanks Neil

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  Hi, You do not need UserControls if they are new to you: you can design a TabControl in Visual Designer without UserControls, just click on the tab to show an individual tab page (you may have to try a couple of times to get the page you want), then fill it as usual. IMO it is easier with UserControls though (only if you are used to them that is). :)

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  Fixturized forever. :confused:


                  N 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    Hi, You do not need UserControls if they are new to you: you can design a TabControl in Visual Designer without UserControls, just click on the tab to show an individual tab page (you may have to try a couple of times to get the page you want), then fill it as usual. IMO it is easier with UserControls though (only if you are used to them that is). :)

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    Fixturized forever. :confused:


                    N Offline
                    N Offline
                    nlowdon
                    wrote on last edited by
                    #9

                    Hi Luc, Sorry - i know this is dragging on a bit. I have the tab control functional and populated with my controls already, what i want to do is make some other controls (check boxes etc) appear on the page when the user clicks on a tab. I can code an event if i double click on the page of the tab (in designer) but that doesn't help work. I want the event to run when the user clicks on the tab. It's not the same as clicking on the tab page. Hope this makes sense !

                    L 1 Reply Last reply
                    0
                    • N nlowdon

                      Hi Luc, Sorry - i know this is dragging on a bit. I have the tab control functional and populated with my controls already, what i want to do is make some other controls (check boxes etc) appear on the page when the user clicks on a tab. I can code an event if i double click on the page of the tab (in designer) but that doesn't help work. I want the event to run when the user clicks on the tab. It's not the same as clicking on the tab page. Hope this makes sense !

                      L Offline
                      L Offline
                      Luc Pattyn
                      wrote on last edited by
                      #10

                      Clicking on any tab fires the SelectedIndexChanged event; so you should add a handler for that event, get the new tab page index from the SelectedIndex property, and act accordingly in your handler's code. I find myself adding a switch statement quite often in such a handler. In order to add a handler, you can use Visual Designer, click the tab control, get its properties, get the events pane, and double-click the row for SelectedIndexChanged. That will create an empty handler, and generate the wiring for it. Or you can add it just by editing the code... (everything Designer does, you can code yourself also). :) ?

                      Luc Pattyn [Forum Guidelines] [My Articles]


                      Fixturized forever. :confused:


                      modified on Wednesday, December 17, 2008 5:45 PM

                      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