Results 1 to 8 of 8

Thread: How do I reference a control in an MDI childform

  1. #1

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366

    How do I reference a control in an MDI childform

    I have a control in an MDI child form, named myControl

    From the parent window, how can I reference myControl?

    I have tried Me.ActiveForm.Controls("myControl")

    but that doesn't work, any ideas?

  2. #2
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    The best way is to create your child forms by declaring them like this:
    VB Code:
    1. Private Child1 As New Form2 'Form level variable....
    2. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3.     Child1.Show
    4.     Dim sCtrlName As String
    5.     sCtrlName = Child1.myControl.Name
    6.     MessageBox.Show(sCtrlName)
    7. End Sub

  3. #3

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Thanks Cyberhawke,

    That works perfectly!

  4. #4
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    No problem, glad I could help

  5. #5

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    One question on this though, how do I make sure I am calling the Active MDI form?

  6. #6
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    I'll have to play around with that and get back to you, I should have something by tomorrow.

  7. #7
    Hyperactive Member CyberHawke's Avatar
    Join Date
    May 2004
    Location
    Washington DC
    Posts
    477
    Got it faster than I thought

    This should have all the code you need to get crankin with your mdi apps
    Attached Files Attached Files

  8. #8

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366
    Thansk Cyberhawke,

    I am cooking now with the MDI, although still having a few other probs. Check my latest post.

    Thanks

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