C# 制作winform切换标签
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/397851/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Making winform switch tabs
提问by Vordreller
I'm making a winform in C# using Visual Studio 2008.
我正在使用 Visual Studio 2008 在 C# 中制作一个 winform。
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.
目前,我有一个 tabcontrol,包含 2 个选项卡。在第一个中,有一个按钮。当我点击它时,我必须被带到第二个选项卡。
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.
额外信息:我的变量名为 tabControl1、textTab 和 logTab。
I'm in textTab, click on a button there and I want to be taken to logTab. That's it basically.
我在 textTab 中,单击那里的按钮,然后我想进入 logTab。基本上就是这样。
采纳答案by Matt Brunell
Did you try this?
你试过这个吗?
tabControl1.SelectedTab = logTab;
回答by rdeetz
You can set either the SelectedIndex property or the SelectedTab property of the tab control to switch tabs.
您可以设置选项卡控件的 SelectedIndex 属性或 SelectedTab 属性来切换选项卡。