Forms inside Splitcontainer

Hi all,

In my application "Main Form" I have a splitcontainer which has a treeview control on the left container... What I want to do is load forms inside my applicaition into the right container...

Is this possible, and how can I do it

Thanks



Answer this question

Forms inside Splitcontainer

  • Alex2003

    Why not create UserControl custom controls rather than actual Form instances. If you must use a Form then you need to set the owner of the form as the main form and tell the form to have no border.

    Phil Wright
    http://www.componentfactory.com
    Free user interface controls for .NET2


  • gssi

    Thanks,

    This Issue has been resolved


  • ttthanh23

    Hi,

    In addition to Phil's response, you also need to set the Form's TopLevel property to False, this is to allow the docking of your Form inside another Form (or any container).

    I had this discussed before, but I can't find my thread regarding this topic. In any case, you can look at this thread:

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=169402&SiteID=1


    Best Regards,

    -chris

  • uchimoto

    Hi.... no my problem isn't solved, using user controls isn't gonna work for me.. I'm thinking an MDI parent kind of way... but not sure... any ideas


  • dsmithwv

    Hi all,

    I'm trying to open child forms in a splittercontainer, and almost got it.

    In Panel 1 (Left) of my splittercontainer, I've got a treeview with a list of all my forms in my project. Then, what I want to do, is open the form I click on in the treeview, in panel 2.

    To achieve this, I save the form name in the TAG property in my treeview's node. I'm trying something like this to open the form, but I seem to be stuck...

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

    Dim Childform As Windows.Forms.Form

    FormLoadName = Me.TreeView1.SelectedNode.Tag

    Dim FrmtoLoad As New FormLoadName

    FrmtoLoad.TopLevel = False

    FrmtoLoad.ShowInTaskbar = False

    FrmtoLoad.Visible = True

    Me.SplitContainer1.Panel2.Controls.Add(FrmtoLoad)

    End Sub

    The error I'm getting from intellisense is "Type FormLoadName" is not defined...."

    How can I set the instance of form to open, in a better way, dynamically, as I want to do this

    Thanks


  • polmau

    Hello Rudi.

    I'll give this a shot. From the code you've provided it looks like you're missing a few intermediate steps. First of all you're grabbing the name of the form out of the Treeview's selectednode tag which is fine The problem arises when you try to create a new Form object as this string rather than as the Form you want to load. What I would recommend instead is to use the My.Forms namespace (http://msdn2.microsoft.com/en-us/library/87y2hdsf.aspx) and iterate through the project's forms to locate the correct one.

    Unfortunately your end-goal of adding a form as a control to a splittercontainer panel isn't going to work out. You can't add a form to a panel in this manner. What you can do is create a panel at the base of the form you want to add, add all your controls to that, and then add that panel to your splittercontainer panel.

    Does that make sense This would all look like:

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect

    ' Clear any existing child controls
    Me.SplitContainer1.Panel2.Controls.Clear()

    ' Select and load the appropriate child panel
    Select Case e.Node.Tag
    Case "Form2"
    Me.SplitContainer1.Panel2.Controls.Add(My.Forms.Form2.Panel1)
    Case "Form3"
    Me.SplitContainer1.Panel2.Controls.Add(My.Forms.Form3.Panel1)
    End Select

    End Sub



  • aftershock

    Hi JRQ,

    Sorry for only responding now, I got caught up in another project.

    Thanks for the reply, I am almost there, but not quite yet, maybe I'm just not getting what you're saying.

    ok, so I got my parent form.... Form 1, which is an MDI container.  On that... I add a panel, and dock it in the parent container How would I dock it only to the left, and specify a width

    Do I add and dock the splitter inside the panel I just added Sorry if I'm sounding stupid, I'm a bit new to windows forms.

    Thanks so far

    Rudi


  • MattP65

    Set your Top Level form to MDIParent (IsMDIContainer = true), add a panel and dock it to the left, add a splitter, put your treeview inside the panel, then you're all set. The right panel (dark gray background) is the MDI Container.

    If  you don't want an MDI approach. Check this thread.

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=412838&SiteID=1

    The form settings are as follows;
                frm.ShowInTaskbar = false;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.ControlBox = false;
                frm.TopLevel = false;
                frm.Text = "";
                frm.Visible = true;
                this.panel1.Controls.Add(frm);

  • zoxter

    Set the PANEL to Dock property to LEFT. The SPLITTER should be outside the PANEL also docked LEFT(this is the default). Drop the treeview into the PANEL and set the dock property of the treeview to FILL.

  • HVE

    Hi JRQ,

    Sorry for only responding now, I got caught up in another project.

    Thanks for the reply, I am almost there, but not quite yet, maybe I'm just not getting what you're saying.

    ok, so I got my parent form.... Form 1, which is an MDI container. On that... I add a panel, and dock it in the parent container How would I dock it only to the left, and specify a width

    Do I add and dock the splitter inside the panel I just added Sorry if I'm sounding stupid, I'm a bit new to windows forms.

    A bit more about my app....

    At the moment, I've got a form that's got my toolbar controls and menu and statusbar that I want. that's just a normal form... when I make that the mdi parent (is that what I'm supposed to do ) the whole are, obviously turns dark gray,

    when I add a panel and splitcontainer, that then fills up all the mdi space, which leaves me with no dark gray background.... Now... What I want to do is,

    The Mdi container, so to speak, should be on the right of the splitcontainer, so that all my forms that I load, shows up on the right, and my treeview in the left box of the splitter, is always visible, or collapsable.... Understand what I'm getting at So when I user clicks on an item on the treeview, the form is opened in the right panel... so I will always have only one, main window, and all the rest of the forms load on the right.

    Hope that makes my situation clearer..

    Thanks so far

    Rudi


  • ColinMcF

    hi,

    Is your problem solved

    Thank you,
    Bhanu.



  • Forms inside Splitcontainer