perpetual_dream

Hello,

I have already built my interface using tabs. I managed to hide the tabpages headers with following code....

Code Snippet

Me.TabControl1.Region = New Region(New RectangleF(Me.TabPage1.Left, Me.TabPage1.Top, Me.TabPage1.Width, Me.TabPage1.Height))

Yet the page itself didnt occupy the place of the page header... and empty space appeared instead of the tabpages themselves being pushed to the top. I don't know how I can manage to make the tab page occupy all the space including the tab page header space. Here is a screenshot for the form am working on:

http://www.firefox-start.com/screenshot/tab-headers.PNG

Thanks



Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

Dave299

There are bound to be much better ways but you could just move it upwards by the height of the tabs and increase its height by the same amount. Do this before setting the region.





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

perpetual_dream

Dave299 wrote:

There are bound to be much better ways but you could just move it upwards by the height of the tabs and increase its height by the same amount. Do this before setting the region.

Could you further explain how





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

Dave299

A bit like this:

Dim HeightOfTabs As Integer = 24

TabControl1.Top -= HeightOfTabs

TabControl1.Height += HeightOfTabs

Me.TabControl1.Region = New Region(New RectangleF(Me.TabPage1.Left, Me.TabPage1.Top, Me.TabPage1.Width, Me.TabPage1.Height))





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

perpetual_dream

A stupid question: How is the heightoftabs calculated what do u mean by it





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

Dave299

I didn't calculate it - I guessed.

Actually there's no need to guess if you do this:

Dim HeightOfTabs As Integer = TabControl1.Height - TabPage1.Height





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

perpetual_dream

as if nothing has happened, by the end the tabcontrol1 redraws itself and it occupies the same region as

Me.TabControl1.Region = New Region(New RectangleF(Me.TabPage1.Left, Me.TabPage1.Top, Me.TabPage1.Width, Me.TabPage1.Height)) as if the lines of code you've suggested had no effect. Why

here is the code I've used:

Code Snippet

Dim HeightOfTabs As Integer = TabControl1.Height - TabPage1.Height

TabControl1.Top -= HeightOfTabs

TabControl1.Height += HeightOfTabs

Me.TabControl1.Region = New Region(New RectangleF(Me.TabPage1.Left, Me.TabPage1.Top, Me.TabPage1.Width, Me.TabPage1.Height))





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

Dave299

Maybe I've misunderstood what you are trying to do.

This works for me. Click on Page 2 and it expands to fill the whole area of the control. Is that not what you wanted.

Code Snippet

Public Class Form1

Dim WithEvents TC1 As New TabControl

Dim TP1 As New TabPage("Page 1")

Dim TP2 As New TabPage("Page 2")

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

TC1.SetBounds(0, 0, 250, 250)

TC1.Font = New Font("Arial", 18, FontStyle.Bold)

TP1.BackColor = Color.Yellow

TC1.TabPages.Add(TP1)

TP2.BackColor = Color.White

TC1.TabPages.Add(TP2)

Me.Controls.Add(TC1)

End Sub

Private Sub TC1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TC1.SelectedIndexChanged

Dim HeightOfTabs As Integer

HeightOfTabs = TC1.Height - TP1.Height

TC1.Top -= HeightOfTabs

TC1.Height += HeightOfTabs

Me.TC1.Region = New Region(New RectangleF(TC1.SelectedTab.Left, Me.TC1.SelectedTab.Top, Me.TC1.SelectedTab.Width, TC1.SelectedTab.Height))

End Sub

End Class





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

bdbodger

I can't help wonder what is a tabcotrol that has no tabs . It is no longer a tab control really so isn't there another control you can use like a panel for instance . I am sorry I just don't see the point .





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

perpetual_dream

HOW CAN I USE THE PANEL IN MY CASE





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

Dave299

As bddodger points out what use is a tab conrol if you can't see the tabs.

I think you need to explain what you are trying to do - why did you want to hide the tabs





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

bdbodger

perpetual_dream wrote:
HOW CAN I USE THE PANEL IN MY CASE

You can change what is in the panel or overlap several panels and bring the one you need to the front with Panel1.bringtofront or Panel2.bringtofront or sendtoback either way . That doesn't just work for the designer but from code as well . If they are at the same location and are the same size then you will only see the one that is at the front .





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

perpetual_dream

Thanks Smile I'll use panels instead Smile





Re: Visual Basic Express Edition How to hide tabcontrol tabpages headers?

HidekiAIkeda

There are usages for hiding Tabs in the TabControl...

I wanted a quick-and-dirty "Wizard" like dialog pop-up, and the easiest way to do this is via using TabControl pages and make each TabPages into a form of questions, radio-checkbox and listbox, etc. Then you add (for example) a "NEXT", "BACK" and "CANCEL" button outside the TabControl which will control the SelectedIndex and so on. Whenever the user hits the NEXT button, it went to the next TabPage, etc.

As for others, at the end, the easiest method (yet again, the "quick-and-dirty") which I came up with for my term was to just place a GroupBox (or any object which is allowed to overlap) and place empty string as its Text. Oh and don't forget to Anchor it so if the dialog box is stretched, it will stay on top. Obviously, there are 2 issues with this:

1. It looks (not bad but still) ugly - but if it is not for comercial purpose and only for internal tools usage, you can probably get away with it.

2. You have to move (or place it behind) the obstruction (in my case, empty GroupBox) when you want to add/edit/switch TabPages