Results 1 to 9 of 9

Thread: [RESOLVED] MDI childforms probleem.

  1. #1

    Thread Starter
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Resolved [RESOLVED] MDI childforms probleem.

    Hi all,

    I want to create an arraylist from MDI childforms and I did it like this:

    vb.net Code:
    1. Dim sl As New SortedList(Of Integer, Form)
    2.         Dim i As Integer
    3.         Dim form As Form
    4.         For Each form In Me.MdiChildren
    5.             sl.Add(CInt(form.Text), form)
    6.         Next
    7.         form = New Form
    8.         form.MdiParent = Me
    9.         If sl.Count > 0 Then
    10.             For i = 1 To Integer.MaxValue
    11.                 If sl.Keys.IndexOf(i) = -1 Then Exit For
    12.             Next
    13.             form.Text = i.ToString
    14.         Else
    15.             form.Text = "1"
    16.         End If
    17.         form.Show()

    It's working great, that means that if I delete a childform for example number 2 from all 3 then it creats first number 2 again and then number 4.

    Now the problem is that It only shows the childformnumber in the parentformtext instead of the name and number of that childform,like this: parentform - childform 1
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  2. #2
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: MDI childforms probleem.

    I don't know if i understand, but you're saying that when you have your form maximized and the mdi children maximized to, you only see FORMPARENTTEXT - NUMBER, instead of FORMPARENTTEXT - CHILDFORM - NUMBER?

    I think that's the normal behavior, you set the text of your child form's like this,
    vb Code:
    1. form.Text = i.ToString
    , so the name will be (1,2,3), then it's normal that you only see the number, nothing more...

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  3. #3
    Hyperactive Member snakeman's Avatar
    Join Date
    Aug 2006
    Posts
    351

    Re: MDI childforms probleem.

    i don't test it but i think because
    i.tostring is the form number
    so
    Code:
      form.Text = i.ToString
    is returning only numbers

    i didn't test so i guess this is
    sorry if i was wrong or if i missed understand you

  4. #4
    Hyperactive Member snakeman's Avatar
    Join Date
    Aug 2006
    Posts
    351

    Re: MDI childforms probleem.

    sorry mickey i didn't see your post

  5. #5

    Thread Starter
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: MDI childforms probleem.

    Hi,

    Yes you're right that gives me only numbers, but when I use thei;

    vb Code:
    1. form.Text = "Childform" & " " &  i.ToString

    Then it gives me an error.

    the convertion from Child 2 to type Long is invalid.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  6. #6
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: MDI childforms probleem.

    That error occurs when you are adding the items to the list...

    Try to replace by this:
    VB.NET Code:
    1. sl.Add(CInt(Form.Text.Substring(Form.Text.IndexOf(" ") + 1)), Form)

    That's because your sorted list it's of integers...
    Last edited by mickey_pt; Aug 11th, 2009 at 04:12 AM. Reason: Info

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  7. #7

    Thread Starter
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: MDI childforms probleem.

    Hi mickey,

    It's nearly working, the only problem is that it gives me only the number for the first childform and not the childform - number, but from the second childform it gives me the proper text.
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

  8. #8
    Frenzied Member mickey_pt's Avatar
    Join Date
    Sep 2006
    Location
    Corner of the Europe :)
    Posts
    1,959

    Re: MDI childforms probleem.

    You must set to the first one to....

    VB.NET Code:
    1. form.Text = "Childform 1"

    Rate People That Helped You
    Mark Thread Resolved When Resolved

  9. #9

    Thread Starter
    PowerPoster sparrow1's Avatar
    Join Date
    May 2005
    Location
    Globetrotter
    Posts
    2,820

    Re: MDI childforms probleem.

    Hi Mickey,

    Thanks, it's working now.
    Here's the whole code:

    vb Code:
    1. Dim sl As New SortedList(Of Integer, Form)
    2.         Dim i As Integer
    3.         Dim form As child
    4.  
    5.         For Each form In Me.MdiChildren
    6.             sl.Add(CInt(form.Text.Substring(form.Text.IndexOf(" ") + 1)), form)
    7.  
    8.         Next
    9.  
    10.         form = New Child
    11.         form.MdiParent = Me
    12.  
    13.         If sl.Count > 0 Then
    14.             For i = 1 To Integer.MaxValue
    15.                 If sl.Keys.IndexOf(i) = -1 Then Exit For
    16.             Next
    17.             form.Text = "Child" & " " & i.ToString
    18.         Else
    19.             form.Text = "Child 1"
    20.         End If
    21.         form.Show()
    Wkr,
    sparrow1

    If I helped you, don't forget to Rate my post. Thank you

    I'm using Visual Studio.Net 2003 and
    2005
    How to learn VB.Net Create setup with VB 2005 Drawing for beginners VB.Net Tutorials GDI+ Tutorials
    Video's for beginners

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