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. Is it possible to disable Tabs in TabControl?

Is it possible to disable Tabs in TabControl?

Scheduled Pinned Locked Moved C#
question
10 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.
  • T Offline
    T Offline
    The Cyclone
    wrote on last edited by
    #1

    Hi, I'm building an application which has 3 forms (really large input data required, huh). I have put these 3 forms in a tab control. Now the requirement is, before filling form 1, i cannot move to form 2 & so on. So, can i disable the tab 2 & 3? I don't want to disable all group controls. It would be nice if i can stop the user from going to those tab panes. I can enable tab 2 after clicking button 'Next' which is in tab 1. Same thing i have to repeat for tab 2. obviously, i can use 2 forms by show & hide tactic, but for some reason, it would be nice if i can use Tab control. :) Thanx in advance...

    C N 2 Replies Last reply
    0
    • T The Cyclone

      Hi, I'm building an application which has 3 forms (really large input data required, huh). I have put these 3 forms in a tab control. Now the requirement is, before filling form 1, i cannot move to form 2 & so on. So, can i disable the tab 2 & 3? I don't want to disable all group controls. It would be nice if i can stop the user from going to those tab panes. I can enable tab 2 after clicking button 'Next' which is in tab 1. Same thing i have to repeat for tab 2. obviously, i can use 2 forms by show & hide tactic, but for some reason, it would be nice if i can use Tab control. :) Thanx in advance...

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      There is an enabled property, but that kind of defeats the purpose of a tab control, sounds like you want a wizard, really.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      N T 2 Replies Last reply
      0
      • T The Cyclone

        Hi, I'm building an application which has 3 forms (really large input data required, huh). I have put these 3 forms in a tab control. Now the requirement is, before filling form 1, i cannot move to form 2 & so on. So, can i disable the tab 2 & 3? I don't want to disable all group controls. It would be nice if i can stop the user from going to those tab panes. I can enable tab 2 after clicking button 'Next' which is in tab 1. Same thing i have to repeat for tab 2. obviously, i can use 2 forms by show & hide tactic, but for some reason, it would be nice if i can use Tab control. :) Thanx in advance...

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        If you need to stop user going to the second tab before finishing first tab, set a flag variable, and update it when the process finishes in the first tab. When user clicks the second tab, handle the event and check the flag value. If the process is not completed, set the SelectedIndex value to select the current tab again. Alternatively, you can disable all the controls in tab page, but user will be able to see that tab. For that use the following code

        Control cn = tabPageName as Control;
        cn.Enabled = false;

        Hope it helps

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

        T 1 Reply Last reply
        0
        • C Christian Graus

          There is an enabled property, but that kind of defeats the purpose of a tab control, sounds like you want a wizard, really.

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          Christian Graus wrote:

          There is an enabled property

          I was also thinking the same, but tabpages don't have a Enabled property. Tab control do have, but it disables the whole control.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

          C 1 Reply Last reply
          0
          • N N a v a n e e t h

            If you need to stop user going to the second tab before finishing first tab, set a flag variable, and update it when the process finishes in the first tab. When user clicks the second tab, handle the event and check the flag value. If the process is not completed, set the SelectedIndex value to select the current tab again. Alternatively, you can disable all the controls in tab page, but user will be able to see that tab. For that use the following code

            Control cn = tabPageName as Control;
            cn.Enabled = false;

            Hope it helps

            All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

            T Offline
            T Offline
            The Cyclone
            wrote on last edited by
            #5

            I'm currently using this 'setting a flag' option. But i thought, there may be some another option for this... so i did asked the question. Thanx for help...

            N L 2 Replies Last reply
            0
            • C Christian Graus

              There is an enabled property, but that kind of defeats the purpose of a tab control, sounds like you want a wizard, really.

              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              T Offline
              T Offline
              The Cyclone
              wrote on last edited by
              #6

              Christian Graus wrote:

              There is an enabled property

              There's no Enable property for individual tabs, but it is for whole tab control.

              Christian Graus wrote:

              sounds like you want a wizard

              I don't have any idea about this 'wizard' thing... Ss it available for win app (as it is in web app)? If you mean to say 'wizard' like something, then yes, i want to do somewhat that kind of thing...

              C 1 Reply Last reply
              0
              • T The Cyclone

                I'm currently using this 'setting a flag' option. But i thought, there may be some another option for this... so i did asked the question. Thanx for help...

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Have you tried my second approach ? As CG said, tab control is not the appropriate control for this scenario. CP having an article on using wizards with winforms. Do a search for that.

                All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                1 Reply Last reply
                0
                • T The Cyclone

                  I'm currently using this 'setting a flag' option. But i thought, there may be some another option for this... so i did asked the question. Thanx for help...

                  L Offline
                  L Offline
                  Laddie
                  wrote on last edited by
                  #8

                  My one cent to this. You can group all controls in different tab panels and in individual panel controls. Now you can use your flag to enable or disable the panels.This is the same idea navneeth said but just to ease the number of controls you need to enable or disable. May be you can consider setting the flag to do this in the tab change event.

                  Thanks Laddie Kindly rate if the answer was helpful

                  1 Reply Last reply
                  0
                  • N N a v a n e e t h

                    Christian Graus wrote:

                    There is an enabled property

                    I was also thinking the same, but tabpages don't have a Enabled property. Tab control do have, but it disables the whole control.

                    All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    OK - I wasn't sure, I meant to say, 'I think there's an enabled property'. But, I recall I've always had to remove tabs rather than disable them

                    Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                    1 Reply Last reply
                    0
                    • T The Cyclone

                      Christian Graus wrote:

                      There is an enabled property

                      There's no Enable property for individual tabs, but it is for whole tab control.

                      Christian Graus wrote:

                      sounds like you want a wizard

                      I don't have any idea about this 'wizard' thing... Ss it available for win app (as it is in web app)? If you mean to say 'wizard' like something, then yes, i want to do somewhat that kind of thing...

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      The obvious way to do a wizard, in either a web or windows app, is to create controls that represent the stages of the wizard, and step through which control is visible as you hit next or previous. I believe there's a wizard control built in for web apps, but a wizard for winforms done with controls is pretty easily done. As the controls all exist on the page, they also all hold their state for when you click 'finish'

                      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                      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