Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making winform switch tabs

I'm making a winform in C# using Visual Studio 2008.

Currently, I have a tabcontrol, containing 2 tabs. In the first the, there is a button. When I click it, I must be taken to the second tab.

Problem is, I don't know how. I've tried debugging, looking into al kinds of Properties and messing around with them, but I found nothing that helps.

Does anybody here know how to pull this off?

Extra info: my variables are named tabControl1, textTab and logTab.

I'm in textTab, click on a button there and I want to be taken to logTab. That's it basically.

like image 214
Vordreller Avatar asked Dec 29 '08 14:12

Vordreller


People also ask

How do I create tabs in WinForms?

To create a TabControl control at design-time, you simply drag and drop a TabControl control from Toolbox onto a Form in Visual Studio. After you drag and drop a TabControl on a Form, the TabControl1 is added to the Form and looks like Figure 1. A TabControl is just a container and has no value without tab pages.

How do you switch tabs in C#?

We can switch one tab to another tab with Selenium webdriver in C#. Sometimes on clicking a link or a button, we can have multiple tabs opened in the same browser. By default, the webdriver can access only the parent tab. To access the second tab, we have to switch the driver focus with the help of the SwitchTo().

Is WinForm deprecated?

Win Form has been used to develop many applications. Because of its high age (born in 2003), WinForm was officially declared dead by Microsoft in 2014. However, Win Form is still alive and well.


2 Answers

Did you try this?

tabControl1.SelectedTab = logTab;
like image 182
Matt Brunell Avatar answered Oct 12 '22 05:10

Matt Brunell


You can set either the SelectedIndex property or the SelectedTab property of the tab control to switch tabs.

like image 43
rdeetz Avatar answered Oct 12 '22 04:10

rdeetz