forms

Do you need something made? then ask in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
5 posts Page 1 of 1
Contributors
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

forms
Mark
hello,

can anyone tell me how to open two forms at once when you start the program but one has to be on the left of the main form can anyone help me please?
http://www.mbappz.com
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: forms
mandai
To add a new form to a project you right click the solution explorer then choose to add, then new windows form.
Once you have added it you can make it appear with Form.Show() and Form.ShowDialog().

If you want it to appear to the left of an existing form then before you show it you could set the StartPosition to Manual and use code like this:
Code: Select all
newForm.Location = new Point(Me.Location.X - newForm.Width, Me.Location.Y)
User avatar
Mark
VIP - Donator
VIP - Donator
Posts: 372
Joined: Mon Aug 17, 2009 10:35 pm

Re: forms
Mark
mandai wrote:
To add a new form to a project you right click the solution explorer then choose to add, then new windows form.
Once you have added it you can make it appear with Form.Show() and Form.ShowDialog().

If you want it to appear to the left of an existing form then before you show it you could set the StartPosition to Manual and use code like this:
Code: Select all
newForm.Location = new Point(Me.Location.X - newForm.Width, Me.Location.Y)
I tried this code
Code: Select all
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Form2.Location = New Point(Me.Location.X - Form2.Width, Me.Location.Y)
        Form2.ShowDialog()
    End Sub
But it still dosent work it shows form 2 and not form1?
http://www.mbappz.com
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: forms
CodenStuff
Hello,

Put the code into the "Form_Shown" event instead of "Form_Load":
Code: Select all
Private Sub Form1_Shown(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Shown
        Dim SecondForm As New Form2
        SecondForm.Location = New Point(Me.Bounds.Left - SecondForm.Width, Me.Location.Y)
        SecondForm.ShowDialog()
    End Sub
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
mandai
Coding God
Coding God
Posts: 2585
Joined: Mon Apr 26, 2010 6:51 pm

Re: forms
mandai
If you have it show the form in the load event and you want it on the left, you need to change Form2.StartPosition to FormStartPosition.Manual.
5 posts Page 1 of 1
Return to “Tutorial Requests”