TabControl不显示 [英] TabControl does not display
本文介绍了TabControl不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常简单的.net c#vs 2012应用程序。我正在学习以编程方式使用tabcontrol。我一直在寻找几个小时,找不到我做错了什么。我下面的简单代码没有显示在我的主表单上。我所看到的每个样本和示例都不超过这个,但这并没有显示出来。显然我错过了一些东西。
感谢您的帮助...
I have a pretty simple .net c# vs 2012 app. I'm learning to use the tabcontrol programatically. I've been looking for a few hours and cannot find what I am doing wrong. My simple code below does not show on my main form. Every sample and example that I have looked at does not more than this and yet this does not show. Obviously I am missing something.
Thanks for any help...
private void Form1_Load(object sender, EventArgs e)
{
TabPage newPage = new TabPage("New Page");
TabControl tabControl = new System.Windows.Forms.TabControl();
tabControl.TabPages.Add(newPage);
}
推荐答案
将newPage选项卡添加到tabControl,但是你从不添加tabControl到你的表单。试试这个...
You add the newPage tab to the tabControl, but you never add the tabControl to your form. Try this...
private void Form1_Load(object sender, EventArgs e)
{
TabPage newPage = new TabPage("New Page");
TabControl tabControl = new System.Windows.Forms.TabControl();
tabControl.TabPages.Add(newPage);
this.Controls.Add(tabControl);
}
谢谢...我看到的演示必须通过设计师添加代码,但无论如何,这确实有效...非常感谢...
Thank you...the demos I saw must have had that code added perhaps via the designer but in any event, that did work...thanks a lot...
这篇关于TabControl不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文