-4

I have a button, that when clicked it creates and displays various controls such as, text boxes and labels.

However, I want it to display on a Tabpage. At the moment it shows up on the original form background.

4

1 回答 1

5

而不是this.Controls.Add(...),您可以将其添加到您想要的TabPage而不是tabPage1.Controls.Add(...).

或者,如果您正在创建一个新的TabPage,请将控件添加到其中,然后添加TabPageTabControl

TabPage tp = new TabPage();
tp.Text = "New Tab";

TextBox tb = new TextBox();
tp.Controls.Add(tb);

tabControl1.TabPages.Add(tp);
于 2013-05-17T02:05:02.047 回答