to open a MDIChild from my main MDIparent form I would use

     Dim ChildForm As New FrmComponent
     ChildForm.MdiParent = Me
    m_ChildFormNumber += 1
    ChildForm.Text = "Add & Edit Components"
    ChildForm.Show()

But I want to open another from from FrmComponent which used the same MDIParent.
at the moment I am using the code below but this opens the form outside the MDIParent

    Dim ChildForm As New FrmComboMaint
    ChildForm.Text = "Add & Edit Drop Down Items"
    ChildForm.Show()
    Me.lbAddOperation.Visible = False
    Me.lbrefreshOperation.Visible = True
    If _Journaling = True Then NewJournal("FrmComponents", "Add New Material", "")

My MDIParent is called FrmMain

Hope someone can help

Hi,

You need to select in the properties of your mdiparentform: IsMdiContainer=true

I dont know if I understand your problem right but I think this would help you.

        FrmComponent.MdiParent = Me 'Me is your MDIparent Form name
        FrmComponent.Show()

Don't forget to mark this issue as solved :) Good luck

A sub might be useful:

Private Sub CreateChild(Title As String)
    Dim ChildForm As New FrmComponent
    ChildForm.MdiParent = Me
    m_ChildFormNumber += 1
    ChildForm.Text = Title
    ChildForm.Show()
End Sub

Now whenever you need a new form of type FrmComponent simply call CreateChild("My New Title")

Sorry let me try to explain in more detail
I have a MDIParent called FrmMain which is set as IsMdiContainer=true

I open my first MDI Child in the MDIContainter (Called FrmComponents) using this code

Dim ChildForm As New FrmComponent
ChildForm.MdiParent = Me
m_ChildFormNumber += 1
ChildForm.Text = "Add & Edit Components"
ChildForm.Show()

Now I want to open a second MDIChild from the FrmComponent (which is a child)
in the MDIcontainter (FrmMain)

is this possible?

Yes, it is possible. I just tried it and it works perfectly for me.

You could put my sub in the mdiparent and make it public, then you can call it from any other form.

Here's an example of how my sub would work:

Form1 is MDIParent:

Public Class Form1

    Public Shared m_ChildFormNumber As Integer = 0
    'Start with one child form created
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CreateChild("Child" + m_ChildFormNumber.ToString)
    End Sub
    'The sub to create child forms
    Public Sub CreateChild(ByVal Title As String)
        Dim ChildForm As New Form2
        ChildForm.MdiParent = Me
        m_ChildFormNumber += 1
        'I made the name the same as the title.  you could easily add another parameter if you want something different
        ChildForm.Name = Title
        ChildForm.Text = Title
        ChildForm.Show()
    End Sub
End Class

Form2 is MDIChild:

Public Class Form2

    Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button1.Text = Me.Name    
    End Sub
    'Every time this button on any child is clicked a new child is formed child is formed
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.CreateChild("Child" + Form1.m_ChildFormNumber.ToString)
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.