0

I want to make buttons change Tabs but i want the tabcontrol to be invisible (Only the page visible not the tabcontrol buttons).

I have 2 buttons Home and Settings and when the Form starts the Home page is visible and when the user clicks Settings button it changes to the Settings page and the same goes for Home button.

So what i need is for the Home and Settings tab buttons to be invisible and i want to only be able to use the buttons i created to change the pages. Hope someone understands. I use Visual Studio 2015 and C#.

bic
  • 2,201
  • 26
  • 27
xBones
  • 31
  • 5
  • For example the button code is like TabControl1.SelectedTab = "Home" – xBones Aug 13 '17 at 21:58
  • 1
    What frontend are you using? WinForms, WPF, HTML, Android, iPhone, Xamirin? – bic Aug 13 '17 at 22:15
  • Windows forms, of course. – xBones Aug 13 '17 at 22:17
  • 2
    Of course? Then you should probably add this to the question tags. – bic Aug 13 '17 at 22:19
  • You can hide headers in tab control by handling `TCM_ADJUSTRECT` message. For example take a look at [this post](https://stackoverflow.com/a/2342320/3110834) or for a more complete version, take a look at second code block in [this post](https://stackoverflow.com/a/40633229/3110834). – Reza Aghaei Aug 14 '17 at 02:37

1 Answers1

3

Going by the name of your control (TabControl1) I am assuming this is WinForms. You can achieve what you are describing without using a tab control at all, just move the contents of each of your tabs to seperate UserControls and then swap the visibility or positioning (or both) upon each button click.

For Home button click handler:

settingsUserControl.Visible = false;
homeUserControl.Visible = true;

Then repeat the reverse, in the Settings button click handler.

If you are using TabControl for its border, then use a Panel as a container to the UserControls.

In fact, this is similar to how Tab Controls worked in VB6, the control being hidden would be shoved 30,000 Twips off to the left, outside the view port of the tab control.

benPearce
  • 37,735
  • 14
  • 62
  • 96
  • So you're saying i add UserControls and do that? – xBones Aug 13 '17 at 22:33
  • Make two new user controls and place them both on the form that you wish to display them, then control their position and visibility in code based up the users button presses – benPearce Aug 13 '17 at 23:47