|
-
Aug 11th, 2009, 02:53 AM
#1
[RESOLVED] MDI childforms probleem.
Hi all,
I want to create an arraylist from MDI childforms and I did it like this:
vb.net Code:
Dim sl As New SortedList(Of Integer, Form)
Dim i As Integer
Dim form As Form
For Each form In Me.MdiChildren
sl.Add(CInt(form.Text), form)
Next
form = New Form
form.MdiParent = Me
If sl.Count > 0 Then
For i = 1 To Integer.MaxValue
If sl.Keys.IndexOf(i) = -1 Then Exit For
Next
form.Text = i.ToString
Else
form.Text = "1"
End If
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
-
Aug 11th, 2009, 03:48 AM
#2
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, , 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
-
Aug 11th, 2009, 03:58 AM
#3
Hyperactive Member
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
-
Aug 11th, 2009, 04:00 AM
#4
-
Aug 11th, 2009, 04:08 AM
#5
Re: MDI childforms probleem.
Hi,
Yes you're right that gives me only numbers, but when I use thei;
vb Code:
form.Text = "Childform" & " " & i.ToString
Then it gives me an error.
the convertion from Child 2 to type Long is invalid.
-
Aug 11th, 2009, 04:11 AM
#6
Re: MDI childforms probleem.
That error occurs when you are adding the items to the list...
Try to replace by this:
VB.NET Code:
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
-
Aug 11th, 2009, 04:25 AM
#7
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.
-
Aug 11th, 2009, 04:42 AM
#8
Re: MDI childforms probleem.
You must set to the first one to....
VB.NET Code:
form.Text = "Childform 1"
Rate People That Helped You
Mark Thread Resolved When Resolved
-
Aug 11th, 2009, 05:06 AM
#9
Re: MDI childforms probleem.
Hi Mickey,
Thanks, it's working now.
Here's the whole code:
vb Code:
Dim sl As New SortedList(Of Integer, Form) Dim i As Integer Dim form As child For Each form In Me.MdiChildren sl.Add(CInt(form.Text.Substring(form.Text.IndexOf(" ") + 1)), form) Next form = New Child form.MdiParent = Me If sl.Count > 0 Then For i = 1 To Integer.MaxValue If sl.Keys.IndexOf(i) = -1 Then Exit For Next form.Text = "Child" & " " & i.ToString Else form.Text = "Child 1" End If form.Show()
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|