tags:

views:

294

answers:

2

i want to control my tab pages with custom buttons...now i want to hide my tabs from tab controls...how can i do that...

A: 

I do not believe you can hide the tab buttons so to solve your problem don't use tab pages at all - instead use the Panel control.

You will be forced to do a little bit more work but you will get the effect you are after.

To get the same effect as using tabs, use the .visible property to either true or false on each panel.

Rather than having the pain of laying the panels all out nicely in the designer, design with one panel and then when setting .visible = true, also set the .top, .left, .width and .height to the values you need.

Hope this makes sense.

CResults
+1  A: 

This is possible, the native tab control implemented by Windows sends the TCM_ADJUSTRECT message to allow the client to override the size of the tabs. Add a new class to your project and paste the code shown below. Compile. Drop the new control from the top of the toolbox onto your form. At design time it still has the tabs so you can easily switch between the pages. But they'll be gone at runtime.

Public Class MyTabControl
  Inherits TabControl

  Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    '--- Hide tabs by trapping the TCM_ADJUSTRECT message
    If m.Msg = &H1328 AndAlso Not DesignMode Then
      m.Result = CType(1, IntPtr)
    Else
      MyBase.WndProc(m)
    End If
  End Sub
End Class
Hans Passant