|
-
May 2nd, 2013, 08:38 PM
#1
Thread Starter
Addicted Member
display same form multiple times on the screen
Hi folks.
I have a credit card sized form that is currently displaying in the centre of the screen. I also want to display the same form at the edges of the screen by docking. So the form will be displayed 5 times on the screen at the same time. How can I do this?
Thanks in advance.
-
May 2nd, 2013, 09:35 PM
#2
Thread Starter
Addicted Member
Re: display same form multiple times on the screen
I think the solution may be here : http://www.xtremevbtalk.com/showthread.php?t=157867
Will give it a go later and mark resolved if need be.
-
May 2nd, 2013, 10:06 PM
#3
Re: display same form multiple times on the screen
that is not vb.net, note that SET is no longer used in vb.net
to create the new form instances of the same form, you could do:
Code:
For i = 1 To 4
Dim frm = New Form1
frm.Text = "This is form # " & i
frm.Show()
Select Case i
Case 1
'code to send to top left
frm.Top = 0 'example of how to set the form to the top and left
frm.Left = 0
Case 2
'code to send to top right
Case 3
'code to send to top right
Case 4
'code to send to top right
End Select
Next
You can definitely get fancier, dimension the frm variable at a class level. Theres lots of threads on screen bounds, so search that up. You could also do the select-case statement to create the form on each case statement, I just didn't feel like writing it out. Hope this at least gets you into the right direction.
-
May 2nd, 2013, 10:07 PM
#4
Re: display same form multiple times on the screen
There's no need to create an array unless you actually need an array. You simply need to create multiple instances. If you just use the class name then you are using the default instance and there is only ever one default instance at a time. If you want multiple instances then you have to create multiple instances explicitly, which is what most experienced developers do all the time anyway, avoiding default instances altogether. To learn a bit more about default instances, you might like to follow the Blog link in my signature and check out my post on the subject.
-
May 3rd, 2013, 12:12 AM
#5
Thread Starter
Addicted Member
Re: display same form multiple times on the screen
Thanks for the replies. Jcm, your blog is so big that I wouldn't know where to find the part about default instances.
This code partially does what I want. I can set the original form(F1) StartPosition = CenterScreen, but then they all start at the same position. Is there any way I can dock F2-F4 on each edge of the screen? There doesn't seem to be a "Dock" property for starting positions. I would like a form in the centre, and 4 forms on the edges(or even corners). Thank you.
Code:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim F2 As New F1
Dim F3 As New F1
Dim F4 As New F1
Dim F5 As New F1
F1.Show()
F2.Show()
F3.Show()
F4.Show()
F5.Show()
End Sub
End Class
-
May 3rd, 2013, 12:41 AM
#6
Re: display same form multiple times on the screen
 Originally Posted by vbforever23
Thanks for the replies. Jcm, your blog is so big that I wouldn't know where to find the part about default instances.
I think that you could have tried just a bit harder. Like pretty much every blog, it has a list of posts on the right side categorised by year and month. There really aren't all that many entries so it would have taken you at most 30 seconds to expand out each branch and find the one and only post on default instances.
As for positioning the forms, you need to do so manually, which is what the FormStartPosition.Manual value is for. You can then use the Screen.PrimaryScreen.WorkingArea to get the dimensions of the desktop on the first monitor and then set the Location of each form accordingly. It's simple maths to determine the appropriate X and Y coordimates.
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
|