Multiple Instances of the Same Form

2 posts, 0 answers
  1. Samantha
    Samantha avatar
    21 posts
    Member since:
    Apr 2009

    Posted 13 Feb 2015 Link to this post

    I have a dock with multiple Document Windows.  

    I want to open multiple instances of the same form on different document windows.  Each form. although the same, needs to contain different data.

    Every time I open a second instance of the form on a second document window, the first instance of the form on the first document window disappears.  The second instance contains the data from the first instance, when it should be maintaining the data from the second document window.

    Is there any way to get around this?  
  2. Dimitar
    Admin
    Dimitar avatar
    1415 posts

    Posted 17 Feb 2015 Link to this post

    Hi Samantha,

    Thank you for writing.

    I am not sure why you are getting such behavior, however you should be able to add the forms properly with the following code:
    int count = 0;
    private void radButton1_Click(object sender, EventArgs e)
    {
        DocumentWindow newDockWindow = new DocumentWindow();
        newDockWindow.Text = count.ToString();
        newDockWindow.CloseAction = DockWindowCloseAction.Hide;
        RadForm form = new RadForm();
        form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        form.TopLevel = false;
        form.Dock = DockStyle.Fill;
     
        RadTextBox box = new RadTextBox();
        box.Text = "Text Box " + count++;
        box.Location = new Point(100, 100);
        form.Controls.Add(box);
     
        newDockWindow.Controls.Add(form);
        this.radDock1.AddDocument(newDockWindow);
        form.Show();
     
        radDock1.ActiveWindow = newDockWindow;
    }

    I hope this helps. Should you have any other questions do not hesitate to ask.
     
    Regards,
    Dimitar
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top