Results 1 to 3 of 3

Thread: [RESOLVED] MDI Child on Tab of parent.

  1. #1

    Thread Starter
    Lively Member Luc L.'s Avatar
    Join Date
    Jan 2005
    Posts
    122

    Resolved [RESOLVED] MDI Child on Tab of parent.

    Hi,

    I have 3 forms loading to memory in sub main()

    The first form is "frm_Main". Which is the main form. The other two are "frm_1" and "frm_2" which are MDI children of frm_Main. All forms are loaded to memory "as New frm_OriginalForm" (whatever the original is) and the frm_XX name is accessible from any module or form in the project.

    Currently, everything works, however I wish to place a tab control on "frm_Main" and put "frm_1" in tab index 0 and "frm_2" in tab index 2 so that these forms can be tabbed between by the user.

    However, when I put the tab control on my "frm_Main" it covers up the two forms which are currently underneath it. Also, I have no idea where to go from here. Keep in mind that the two children forms are created in run time and are set to be the children in sub main.

    Any help would be appreciated.

    Best Regards,
    Luc L.

  2. #2
    Still learning kebo's Avatar
    Join Date
    Apr 2004
    Location
    Gardnerville,nv
    Posts
    3,762

    Re: MDI Child on Tab of parent.

    you can use the SetParent api to make the tabpage a parent of the child forms

    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         Dim f As New Form
    3.         f.Show()
    4.  
    5.         SetParent(f.Handle.ToInt32, Me.TabPage1.Handle.ToInt32)
    6.  
    7.     End Sub

    hth
    kevin

    ps...
    this only works if form child form runs in the same thread as the parent. Children can't be parented to controls on different threads
    Last edited by kebo; Feb 17th, 2006 at 07:25 PM.
    Process control doesn't give you good quality, it gives you consistent quality.
    Good quality comes from consistently doing the right things.

    Vague general questions have vague general answers.
    A $100 donation is required for me to help you if you PM me asking for help. Instructions for donating to one of our local charities will be provided.

    ______________________________
    Last edited by kebo : Now. Reason: superfluous typo's

  3. #3

    Thread Starter
    Lively Member Luc L.'s Avatar
    Join Date
    Jan 2005
    Posts
    122

    Re: MDI Child on Tab of parent.

    thanks. that did the trick, though i was hoping for a non-api approach.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width