Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Tabcontrol - Hide TabPage Label (Button) Only

Auguy (Programmer) (OP)
10 Mar 09 14:23
I would like to hide the label or button portion only of a tabpage, not remove the entire page. I want to control through the program which page is visible and not let the user click on the label (Buttons) to change tab pages. It seems like there should be a property setting somewhere for this. Something like TabAlignment = "None". I guess I could position the tab control so the user cannot see the label (buttons), just thought there might be an easier way. Maybe an override of the paint method, but I haven't done that before. Any help or suggestions would be appreciated.

Auguy
Northwest Ohio

RiverGuy (Programmer)
10 Mar 09 15:17
There is no way to do it that I know of.

If you're simply wanting to control through code which controls are visible at what time, then just put some panel controls onto your form, fill them with controls, and show or hide them from your code based on your business rules.
Auguy (Programmer) (OP)
10 Mar 09 15:28
Thanks RiverGuy. I played around with moving the tab control so you couldn't see the labels and it didn't look too bad. The tab control is already built and populated with other controls so I really don't want to change it at this point in time. Will test some more and see if moving the tab control will look OK.

Auguy
Northwest Ohio

DaveInIowa (Programmer)
10 Mar 09 16:02
Forgive me if I'm not understanding your question completely. You said you don't want to remove the entire page but what difference would that make if the tab label/button is not visible? The user would not be able to select it anyway would they? Couldn't you just Remove and Add the TabPage to the TabControl's Controls to control the visibility?

CODE

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Static tabPage2Visible As Boolean = True

        If (tabPage2Visible) Then
            TabControl1.Controls.Remove(TabPage2)
        Else
            TabControl1.Controls.Add(TabPage2)
        End If
        tabPage2Visible = (Not tabPage2Visible)

    End Sub
Auguy (Programmer) (OP)
10 Mar 09 16:18
Yes I could just add and remove the pages, but the tab page label would still be visible for the page just added. I don't want the user to see the label of any of the tab pages. I want the program to determine which page is visible. Not a real big deal, just thought it would look better without the label showing.

Auguy
Northwest Ohio

DaveInIowa (Programmer)
11 Mar 09 0:11
How about setting the tab control's SizeMode to Fixed and its ItemSize to 1,1?
Auguy (Programmer) (OP)
11 Mar 09 9:02
Thanks Dave, that will help me hide them because they are so small, but you can still click them. I'm already using the tabcontrol's drawitem to change the background color of the label, maybe I can do something in there to really hide them.

Auguy
Northwest Ohio

markros (Programmer)
28 May 09 10:53
Did you end up writing something? I have a form with TabControl already designed, but now the requirements changed and in one situation I only want to show the first page and in another two other pages.

What would be my simple solution here - I'm still a newbie in WinForms.
markros (Programmer)
28 May 09 14:45
I found this blog, but I don't understand what this code is supposed to do

http://blog.bee-eee.com/2008/01/02/a-hiding-tabcontrol-tabs-in-c/
Auguy (Programmer) (OP)
28 May 09 17:17
I never really finished that test form. If it's not too much trouble then I would add and remove pages as Dave suggested. You could place the tab control at the top of the form so you cannot see the tabs. I did play around with making the itemsize (1,1). You can still see them and click on them but they are very small. I placed a label control in front of the tab control to hide all of the tabs. This seemed to work ok, just make sure if you allow any movement or resizing that thew label stays in place. I reposition the label in the form load so it would always be in the correct spot. You could also reposition it in a re-size event.

Auguy
Northwest Ohio

markros (Programmer)
28 May 09 19:23
In the first case where I only wanted to show one page, I removed two other pages and set Text property of TabControl to 100 spaces.

I applied similar technique in the case of 2 pages.

It is not a perfect solution, but OK with me.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close