Question GUI Help, displaying a new form in the position of the previous one

berniefitz

New member
Joined
Jul 31, 2011
Messages
1
Programming Experience
5-10
Hi there,

I'm currently in the process of building a program that will display one form at a time. Based on clicking a BACK or NEXT button I want the form that opens to display in the same position as the form that just closed (or hid).
I'm trying to make the program look very solid but at the moment I can't seem to figure this out. The code below is what I'm using when changing between forms.

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click        ' Create variables to remember the position of the form we are hiding so that we can open the new form in the same position
        Me.Hide()
        Dim inputForm As Form2
        inputForm = New Form2()
        inputForm.StartPosition = FormStartPosition.CenterScreen
        inputForm.Show()
        ' Setting the object to nothing will release the memory???
        'inputForm = Nothing


    End Sub


If anyone has suggestions, fixes or better approaches to take please let me know. I know more than basic programming but GUI building and VB .NET are both pretty new to me.

Thanks, Bernie.
 
If you want to display a form at a specific location then you must set its Location property. In your case you would get the value from the Location of the previous form. You must also set the StartPosition to Manual.
 
Back
Top