471,336 Members | 1,254 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,336 software developers and data experts.

Adding a Form to a TabPage

TN
I can add a button to a TabPage, how come I can't add a Form? The Form
never gets realized on the page, but a button can :-(

f = new System.Windows.Forms.Form();
b = new Button();
b.Text = "Hello";
f.Text = "NEW";
f.Size = new Size(100, 100);
f.Controls.Add(b);
f.TopLevel = false;
f.Dock = DockStyle.Fill;

t = new TabPage("Cash Receipts");
f.Parent = t;
t.Controls.Add(f);
tabControl1.TabPages.Add(t);
Dec 23 '05 #1
2 7778
TN
TN wrote:
I can add a button to a TabPage, how come I can't add a Form? The Form
never gets realized on the page, but a button can :-(

f = new System.Windows.Forms.Form();
b = new Button();
b.Text = "Hello";
f.Text = "NEW";
f.Size = new Size(100, 100);
f.Controls.Add(b);
f.TopLevel = false;
f.Dock = DockStyle.Fill;

t = new TabPage("Cash Receipts");
f.Parent = t;
t.Controls.Add(f);
tabControl1.TabPages.Add(t);


(sticking tail between legs)

f.Show();

Dec 23 '05 #2
Hi,

what about having a TabControl hosting multiple tabpages each hosting its
own form?
The below works fine for 1 hosted form but as soon as you add further forms
to further tabpages the additionial forms will not show (unless you politely
ask them to do so multiple times and are willing to wait a bit...)
"TN" <ti*******@phreaker.net> wrote in message
news:%2*****************@tk2msftngp13.phx.gbl...
TN wrote:
I can add a button to a TabPage, how come I can't add a Form? The Form
never gets realized on the page, but a button can :-(

f = new System.Windows.Forms.Form();
b = new Button();
b.Text = "Hello";
f.Text = "NEW";
f.Size = new Size(100, 100);
f.Controls.Add(b);
f.TopLevel = false;
f.Dock = DockStyle.Fill;

t = new TabPage("Cash Receipts");
f.Parent = t;
t.Controls.Add(f);
tabControl1.TabPages.Add(t);


(sticking tail between legs)

f.Show();

Feb 26 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by slylos | last post: by
2 posts views Thread by GatorBait | last post: by
11 posts views Thread by Pete Kane | last post: by
1 post views Thread by RobcPettit | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.