adding tabpage to another form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • RobcPettit@yahoo.co.uk

    #1

    adding tabpage to another form

    Hi, I have two forms. From form1(frmMain) I want to add tabpages to
    Form2. In form1 I have:
    frmMain tbe = new frmMain();
    Thread thread = new Thread(new
    ThreadStart(tbe .AddTab));
    thread.IsBackgr ound = true;
    thread.Start();

    In Form2 I have:
    public delegate void mydata(String e);

    public void AddTab()
    {
    if (this.InvokeReq uired)
    {
    this.BeginInvok e(new mydata(TestMeth od),"somestring ");
    }

    else
    {
    TestMethod("rob ");
    }

    }
    private void TestMethod(Stri ng mystring)
    {
    String TabName = "rob";
    TabPage NewTab = new TabPage(TabName );
    tabControl1.Tab Pages.Add(NewTa b);
    }

    It biulds ok, and runs ok, but doesnt show the tabs on Form2.
    The idea is that both forms are open, from form one I scan through a
    list which has been added to a treeview,(this all works). Then click
    the item I want, creating a new tab in form2 each time. Then close
    form1 and work with form2.
    Regards Robert
  • RobcPettit@yahoo.co.uk

    #2
    Re: adding tabpage to another form

    Thankyou for your reply. Both forms are showing. Do you meen the
    reference on the form that I want to add the tab to. If so do I have
    to refer to form2 even though the code is in form2.

    Regards Robert

    Comment

    Working...