Adding a Form to a TabPage

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TN

    Adding a Form to a TabPage

    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.Tab Pages.Add(t);
  • TN

    #2
    Re: Adding a Form to a TabPage

    TN wrote:[color=blue]
    > 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.Tab Pages.Add(t);[/color]

    (sticking tail between legs)

    f.Show();

    Comment

    • RHeuvel

      #3
      Re: Adding a Form to a TabPage

      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" <timnelson@phre aker.net> wrote in message
      news:%23V4coy%2 3BGHA.984@tk2ms ftngp13.phx.gbl ...[color=blue]
      > TN wrote:[color=green]
      >> 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.Tab Pages.Add(t);[/color]
      >
      > (sticking tail between legs)
      >
      > f.Show();
      >[/color]


      Comment

      Working...