在 C# TabControl 上隐藏选项卡标题 [英] Hide Tab Header on C# TabControl

查看:46
本文介绍了在 C# TabControl 上隐藏选项卡标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个包含多个页面的 Windows 窗体应用程序.我正在使用 TabControl 来实现这一点.而不是使用标题在选项卡之间切换,我希望我的应用程序控制它,例如用户填写文本框并单击下一步按钮后,应打开下一个选项卡.

I am developing a Windows Form Application with several pages. I am using a TabControl to implement this. Instead of using the header to switch between tabs, I want my application to control this e.g. the next tab should open after the user has filled in a text box and clicked the next button.

推荐答案

你可以用一个手工制作的面板替换 tabcontrol,模仿你想要的样子:

You can replace tabcontrol with a hand made panel that mimic like you want:

class MultiPagePanel : Panel
{
  private int _currentPageIndex;
  public int CurrentPageIndex
  {
    get { return _currentPageIndex; }
    set
    {
      if (value >= 0 && value < Controls.Count)
      {
        Controls[value].BringToFront();
        _currentPageIndex = value;
      }
    }
  }

  public void AddPage(Control page)
  {
    Controls.Add(page);
    page.Dock = DockStyle.Fill;
  }
}

然后添加页面并设置当前可见页面:

And then add pages and set current visible page:

MultiPagePanel p;

// MyTabPage is a Control derived class that represents one page on your form.
MyTabPage page = new MyTabPage(); 
p.AddPage(page);

p.CurrentPageIndex = 0;

这篇关于在 C# TabControl 上隐藏选项卡标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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