我们可以在tabControl中控制标签页吗? [英] can we control the tab pages in a tabControl?

查看:56
本文介绍了我们可以在tabControl中控制标签页吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在3个单独的按钮中控制3个选项卡页面.此代码不会出现任何错误,但无法正常工作.单击给定按钮时,选项卡页面不会出现.
请帮帮我!

i need to control 3 tab pages in separate 3 buttons.this code doesn''t give any errors but not working as expected.tabpages are not appearing when the given buttons are clicked.
please help me!

private void button1_Click(object sender, EventArgs e)
{
    tabPage1.Show();
}
private void button2_Click(object sender, EventArgs e)
{
    tabPage2.Show();
}
private void button3_Click(object sender, EventArgs e)
{
    tabPage3.Show();
}

推荐答案

您需要像这样设置选定的标签

You need to set the selected tab like so

private void button1_Click(object sender, EventArgs e)
{
  tabControl1.SelectedTab = tabPage1;
}

private void button2_Click(object sender, EventArgs e)
{
  tabControl1.SelectedTab = tabPage2;
}
      
private void button3_Click(object sender, EventArgs e)
{
  tabControl1.SelectedTab = tabPage3;
}


这篇关于我们可以在tabControl中控制标签页吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆