Results 1 to 8 of 8

Thread: [RESOLVED] MDI Child and a Dialog form

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Location
    Bucharest - Romania
    Posts
    5

    Resolved [RESOLVED] MDI Child and a Dialog form

    Hello all,

    I'm having trouble with MDI child and a dialog form. The problem details are listed below:

    1. One MDI Parent form (Form1) with a button on it (Button1).
    2. One Child form of Form1 (name = Form2) with a button (Button2) and a textbox (text_box1).
    3. Another form in the project (not child of Form1 and not MDI Parent) with name Form3. This form has also a button on it (Button3).

    The application behaviour is as follows: the application starts with Form1. Clicking the Button1 will show Form2. Form2 correctly opened as a MDI child. Clicking the Button2 on the Form2 will show Form3 as dialog (Form3.ShowDialog() ). Clicking the Button3 on the Form3 need to do the magical thing - to set/change the text in the Form2's text_box1.

    Tried various examples from this forum. Also followed a lot of examples from net. Nothing works. Tried to create a writable property in the Form2 class but calling it from the Form3 does nothing.

    I tried to access the MDIchildren(ss) while ss loops in MDIchildrens array but I don't know how to access the label control inside the Form2 using this technique. Successfully changed the Form2 caption but no controls are available in VB intellisense - practically correct because VB don't know which form from array I'm referring to.

    Could you please help me with this task? I'm not an experienced programmer but I don't want to skip the MDI section without this.

    Regards,
    Costin

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: MDI Child and a Dialog form

    Code:
    Public Class Form3
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        CType(Form1.ActiveMdiChild, Form2).TextBox1.Text = "Hello"
        Me.Close()
      End Sub
    End Class

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Location
    Bucharest - Romania
    Posts
    5

    Re: MDI Child and a Dialog form

    Actually... it's working! Thank you very much.

    A short question. If I call the dialog using Form3.ShowDialog(me) will ensure that every time the active mdi child is form2? Or by simply launch the Form3 from Form2 button (Button2) will define Form2 as Active MDI Child? Translating this: last focused MDI child is the active mdi child?

    Regards,
    Costin

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: MDI Child and a Dialog form

    Last focused MDI child is the active MDI child, that's correct, yes.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2010
    Location
    Bucharest - Romania
    Posts
    5

    Re: MDI Child and a Dialog form

    Thank you very much for your prompt responses.

  6. #6
    Junior Member
    Join Date
    Jun 2010
    Posts
    19

    Re: [RESOLVED] MDI Child and a Dialog form

    Hi,

    I am unable to make a child form dialog in VB.Net. Below code does not work?

    SoftwareLic.MdiParent = Main
    SoftwareLic.ShowDialog()

    Any help? Thanks!

  7. #7
    Junior Member
    Join Date
    Jun 2010
    Posts
    19

    Re: [RESOLVED] MDI Child and a Dialog form

    Hi Guys,

    What I am trying to do is to keep the child dialog inside the parent container. I found C# example on this link below:

    http://www.codeproject.com/KB/dialog...ed_dialog.aspx

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: [RESOLVED] MDI Child and a Dialog form

    Please don't hijack a resolved thread. Start a new one instead. Here's a site that will translate C# code into VB.
    http://www.developerfusion.com/tools.../csharp-to-vb/

Tags for this Thread

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