B
Bryan
I have a form that contains three panels, separated by
vertical splitters. Each panel has two child panels,
separated by horizontal splitters. Everything is
docked/anchored to fill the entire form container.
So, we have a 3 x 3 grid of resizable panels.
My goal is to save the size/position of each
panel/splitter to a class, so we can reset the controls to
the same size/position that the user left them in.
Here is my class (prop set/get & constructors omitted for
clarity):
Private Class ConsoleLayout
Private mControl As Control
Private mLocation As Point
Private mSize As Size
Private mAnchor As AnchorStyles
Private mDock As DockStyle
End Class
When the form closes, the following code would save the
positions to an array list of these classes:
Private myForms As New ArrayList
Private Sub Save(ByVal sender As System.Object, ByVal
e As System.EventArgs)
myForms.Clear()
Dim theControl As Control
For Each theControl In Me.Controls
myForms.Add(New ConsoleLayout(theControl,
theControl.Location, theControl.Size, theControl.Anchor,
theControl.Dock))
Next
End Sub
And here is the function that should "restore" the
size/position:
Private Sub Save()
Me.SuspendLayout()
Dim myLayout As ConsoleLayout
For Each myLayout In myForms
myLayout.Control.Location = myLayout.Location
myLayout.Control.Size = myLayout.Size
myLayout.Control.Anchor = myLayout.Anchor
myLayout.Control.Dock = myLayout.Dock
Next
Me.ResumeLayout()
End Sub
*** All the left/right positions are proper, however the
top/height positions/sizes don't seem to take
their "saved" settings.
I've inspected the values, and the class properly gets
the "new" values, but the control doesn't "take" the
Top/Height values I send to them.
I've experimented with limiting the Get/Set of just
panels, panels & splitters, etc but that didn't matter.
I also did Suspend Layout for just the panel controls, as
the Windows Form Generator code seems to do when the form
is originally loaded; that too had no affect.
Any ideas?
Regards,
Bryan
vertical splitters. Each panel has two child panels,
separated by horizontal splitters. Everything is
docked/anchored to fill the entire form container.
So, we have a 3 x 3 grid of resizable panels.
My goal is to save the size/position of each
panel/splitter to a class, so we can reset the controls to
the same size/position that the user left them in.
Here is my class (prop set/get & constructors omitted for
clarity):
Private Class ConsoleLayout
Private mControl As Control
Private mLocation As Point
Private mSize As Size
Private mAnchor As AnchorStyles
Private mDock As DockStyle
End Class
When the form closes, the following code would save the
positions to an array list of these classes:
Private myForms As New ArrayList
Private Sub Save(ByVal sender As System.Object, ByVal
e As System.EventArgs)
myForms.Clear()
Dim theControl As Control
For Each theControl In Me.Controls
myForms.Add(New ConsoleLayout(theControl,
theControl.Location, theControl.Size, theControl.Anchor,
theControl.Dock))
Next
End Sub
And here is the function that should "restore" the
size/position:
Private Sub Save()
Me.SuspendLayout()
Dim myLayout As ConsoleLayout
For Each myLayout In myForms
myLayout.Control.Location = myLayout.Location
myLayout.Control.Size = myLayout.Size
myLayout.Control.Anchor = myLayout.Anchor
myLayout.Control.Dock = myLayout.Dock
Next
Me.ResumeLayout()
End Sub
*** All the left/right positions are proper, however the
top/height positions/sizes don't seem to take
their "saved" settings.
I've inspected the values, and the class properly gets
the "new" values, but the control doesn't "take" the
Top/Height values I send to them.
I've experimented with limiting the Get/Set of just
panels, panels & splitters, etc but that didn't matter.
I also did Suspend Layout for just the panel controls, as
the Windows Form Generator code seems to do when the form
is originally loaded; that too had no affect.
Any ideas?
Regards,
Bryan