• 周一. 6月 24th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

TabControl控件和TabPage

admin

11月 28, 2021
TabControl控件和TabPage
TabControl控件可以支持在一个控件里面放置多个选项卡,每个选项卡又可以放置多个控件

由于在控件属性窗口添加选项卡相对比较容易,下面说一下动态创建选项卡 

首先从工具栏拖入一个TabControl控件tabControl1

//创建一个TabPage
TabPage tabPage = new TabPage();
//设置选项卡文本

tabPage.Text = “选项卡1”;

//选项卡名字(可以通过这个名字来访问到tabControl1中的选项卡)
tabPage.Name = “page1”;

//如果选项卡内的控件比较多,则可以添加一个Form控件,但是Form空间的TopLevel要设置为false

Form1 page = new Form1();

page.Name = “formpage”

page.TopLevel = false;

//给Form去边框

page.FormBorderStyle = FormBorderStyle.None;

//把page添加到tabPage中
tabPage.Controls.Add(chatPage);
//在tabPage选项卡中显示出来

page.Show();
//添加选项卡tabPage到TabControl中
tabControl1.TabPages.Add(tabPage);

这样就动态添加了一个选项卡

访问选项卡:

//通过索引访问选项卡

tabControl1.TabPages[0]

//通过TabPage的Name属性访问选项卡

tabControl1.Tabpages[“page1”]

访问选项卡中的控件

tabControl1.TabPages[0].Controls[0];

tabControl1.TabPages[0].Controls[“formpage”];

如果要访问控件中的成员,需要进行类型转换

例如,访问Form1中的成员

Form1 form = tabControl1.TabPages[0].Controls[0] as Form1;

然后通过form来访问Form1的内部成员

原文引入:http://blog.sina.com.cn/s/blog_70bf5798010187t1.html

《TabControl控件和TabPage》有400个想法
  1. Wow, fantastic weblog structure! How lengthy have you
    ever been running a blog for? you made running a blog look easy.
    The overall look of your website is excellent, let alone the
    content material! You can see similar here sklep internetowy

  2. Howdy! Do you know if they make any plugins to help with SEO?
    I’m trying to get my blog to rank for some targeted keywords
    but I’m not seeing very good results. If you know of any please share.

    Thanks! You can read similar article here: AA List

  3. There are a few fascinating points at some point in this post but I do not determine if I see all of them center to heart. There is some validity but I most certainly will take hold opinion until I take a look at it further. Good write-up , thanks so we want much more! Added to FeedBurner also

  4. Why Motorcycle Accident Compensation Isn’t A Topic That People Are Interested In Motorcycle Accident Compensation motorcycle accident lawyer (Serena)

  5. I’m impressed, I must say. Truly rarely do I encounter a weblog that’s both educative and entertaining, and let me tell you, you’ve got hit the nail around the head. Your concept is outstanding; the catch is a thing that insufficient persons are speaking intelligently about. I am happy which i found this at my try to find something relating to this.

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注