I have two forms that are called by the main form. One is named frmEdit, and is invoked by the ShowDialog (modal) method. The other is named frmSearch and is invoked by the Show (non modal) method. In both cases I want to preserve the last window position so each form (class) begins with
Public Class frmEdit (or frmSearch) Dim lastx as Integer = -1 Dim lasty as Integer = -1
in the Shown event handler for each form I have the code
If lastx >= 0 Then Me.Left = lastx Me.Top = lasty End If
and in the FormClosing handler I do
lastx = Me.Left lasty = Me.Top
What I don't understand is why the frmEdit (modal) form remembers its previous position but the frmSearch (non-modal) does not. frmSearch always invokes with lastx and lasty equal to -1. Can someone please explain and suggest a fix?