如何以编程方式选择 .NET CF TabControl 上的选项卡?
使用 .NET Framework 2.0/3.5 TabControl,我可以使用 SelectedTab 属性以编程方式选择选项卡,如下面的代码所示:
//toggles between tabPage1 and tabPage2
private void button1_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabPage1)
tabControl1.SelectedTab = tabPage2;
else
tabControl1.SelectedTab = tabPage1;
}
.NET Compact Framework TabControl 没有像其 .NET Framework 那样的 SelectedTab 属性。 NET 框架的对应部分。 那么,如何以编程方式选择选项卡?
With the .NET Framework 2.0/3.5 TabControl, I can programmatically select a tab using the SelectedTab property as shown in the code below:
//toggles between tabPage1 and tabPage2
private void button1_Click(object sender, EventArgs e)
{
if (tabControl1.SelectedTab == tabPage1)
tabControl1.SelectedTab = tabPage2;
else
tabControl1.SelectedTab = tabPage1;
}
The .NET Compact Framework TabControl doesn't have a SelectedTab property like its .NET Framework counterpart. So, how do I select a tab programmatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
TabControl.SelectedIndex
TabControl.SelectedIndex
我编写了这段代码。 当点击tabPage1时,程序将关闭:
I programmed this code. When click on tabPage1, then the program will close:
我发现当选择TabControl时,它无法正确显示。 看来选择 TabControl 后刷新它很有用。 因此,如果 TabControl 称为 TabForm 并且具有多个选项卡,则可能是:
I found that when the TabControl is selected, it does not display correctly. It seems that after selecting a TabControl it is useful to Refresh it. So, where the TabControl is called TabForm and has multiple Tabs, this might be:
在.Net 4中可以使用
OR
in .Net 4 can use
OR
WPF 代码,试试这个:
WPF code, try this: