How to hide .net tab control's page headers

P

Pasan Indeewara

Hi,
In my C# form I'm using a tab control to switch between various tabs in
order to provide several layouts depending on user levels. I need to hide
the tab page headers, otherwise it's useless because users can see the other
tab page headers. Can someone pls let me know how we can do this in C#.net.

thx in advance.
 
F

Family Tree Mike

Pasan said:
Hi,
In my C# form I'm using a tab control to switch between various tabs
in order to provide several layouts depending on user levels. I need to
hide the tab page headers, otherwise it's useless because users can see
the other tab page headers. Can someone pls let me know how we can do
this in C#.net.

thx in advance.

It sounds like it would be better to create a user control for each
layout, and create a single instance of the correct layout at startup.

You can almost hide the tabs by messing with the ItemSize property, but
I don't see any reason for using the tab page at all.
 
P

Pasan Indeewara

creating a layout and loading it is ok.. but it's like this I need to switch
between views sometimes.. ItemHeight is not a good option. Thx anyway :) I
tried to create a my own page class and make it without header.. but it
wasn't successful.. even though I inherited from it the right class...
 
F

Family Tree Mike

Pasan said:
creating a layout and loading it is ok.. but it's like this I need to
switch between views sometimes.. ItemHeight is not a good option. Thx
anyway :) I tried to create a my own page class and make it without
header.. but it wasn't successful.. even though I inherited from it the
right class...

Then you can put multiple layout user controls on the form and change
which is visible at any given time. Just use the mechanism where you
would have changed tabs to instead change visibility of the layout controls.
 
A

Appr3nt1c3

Then you can put multiple layout user controls on the form and change
which is visible at any given time.  Just use the mechanism where you
would have changed tabs to instead change visibility of the layout controls.

have you tried deleting the other tabpages at runtime? i.e. delete the
tabpages whose level of access is not met by the current user's level.

in your code, you should make sure that you only access the controls
of the displayed tabpages.
 
J

Joe Cool

Hi,
     In my C# form I'm using a tab control to switch between various tabs in
order to provide several layouts depending on user levels. I need to hide
the tab page headers, otherwise it's useless because users can see the other
tab page headers. Can someone pls let me know how we can do this in C#.net.

I accomplish this be defining a second TabControl that is set to not
visible and when I want a TabPage to be invisible, I move it to the
other TabCOntrol. Move it back to make it visible again.\
 
P

Pasan Indeewara

Thanks, but deletion is not going to help since I need to switch between
views time to time. The simplest solution was adding a label to cover the
header parts and use Tab control's Flat button style to show it as a part of
container. this worked :) thanks everyone tried to help... appreciate all
your suggestions...

Then you can put multiple layout user controls on the form and change
which is visible at any given time. Just use the mechanism where you
would have changed tabs to instead change visibility of the layout
controls.

have you tried deleting the other tabpages at runtime? i.e. delete the
tabpages whose level of access is not met by the current user's level.

in your code, you should make sure that you only access the controls
of the displayed tabpages.
 
A

Anja Länge

Pasan said:
In my C# form I'm using a tab control to switch between various
tabs in order to provide several layouts depending on user levels. I
need to hide the tab page headers, otherwise it's useless because
users can see the other tab page headers. Can someone pls let me know
how we can do this in C#.net.

Set the following properties programmatically or by using the designer:

this.tabControl1.Appearance = TabAppearance.FlatButtons;
this.tabControl1.ItemSize = new Size(0, 1);
this.tabControl1.SizeMode = TabSizeMode.Fixed;

It works but leaves a control-colored border to the tabpages - which is okay
if your form has the backcolor set to "control" but looks very ugly with
other backcolors. The alternative is to create various panels with the
different layouts instead of various tabpages and setting the visibility of
the needed panel to true instead of selecting and activating a tabpage.


Anja
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top