In a WinForms 2.0 C# application, what is the typical method used for saving and restoring form position and size in an application?
Related, is it possible to add n
I just stream it out to a separate XML file - quick and dirty and probably not what youre after:
Dim winRect As String() = util.ConfigFile.GetUserConfigInstance().GetValue("appWindow.rect").Split(",")
Dim winState As String = util.ConfigFile.GetUserConfigInstance().GetValue("appWindow.state")
Me.WindowState = FormWindowState.Normal
Me.Left = CType(winRect(0), Integer)
Me.Top = CType(winRect(1), Integer)
Me.Width = CType(winRect(2), Integer)
Me.Height = CType(winRect(3), Integer)
If winState = "maximised" Then
Me.WindowState = FormWindowState.Maximized
End If
and
Dim winState As String = "normal"
If Me.WindowState = FormWindowState.Maximized Then
winState = "maximised"
ElseIf Me.WindowState = FormWindowState.Minimized Then
winState = "minimised"
End If
If Me.WindowState = FormWindowState.Normal Then
Dim winRect As String = CType(Me.Left, String) & "," & CType(Me.Top, String) & "," & CType(Me.Width, String) & "," & CType(Me.Height, String)
' only save window rectangle if its not maximised/minimised
util.ConfigFile.GetUserConfigInstance().SetValue("appWindow.rect", winRect)
End If
util.ConfigFile.GetUserConfigInstance().SetValue("appWindow.state", winState)