Results 1 to 4 of 4

Thread: Getting the Index of a MDI Child Form [Not Solved]

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    15

    Getting the Index of a MDI Child Form [Not Solved]

    I am writing a MDI program and I need to know how I can get the index of a MDI Child Form. Is there any possible way to do this in VB.NET 2005?

    Creating the MDI Child Code:
    1. Dim save As New frmSave
    2.             save.txtExt.Text = ".txt"
    3.             save.MdiParent = MdiParent
    4.             save.Show()

    NOTE: The form that this code is coming from is not the MDI Container.

    Thank you for your help!

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Getting the Index of a MDI Child Form [Not Solved]

    MdiParent is the form whose IsMdiContainer property is True. It has an MdiChildren property, which is a Form array. You can use the Array.IndexOf method to find the index of any form in that array.

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2011
    Posts
    15

    Re: Getting the Index of a MDI Child Form [Not Solved]

    I tried doing that with this code.

    vb Code:
    1. With frmMain
    2.                 Dim frmArr() As Form = .MdiChildren
    3.                 Dim int As Integer
    4.                 int = frmArr.IndexOf(frmArr, Me)
    5. End With

    It has a green line under frmArr.IndexOf Anyway to get rid of that or did I write the code in the wrong way?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,344

    Re: Getting the Index of a MDI Child Form [Not Solved]

    Did you read the documentation for the Array.IndexOf method? If you try something and it doesn't work, reading the instructions should be the first thing you do.

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