Splitter control location

M

Mika M

Hello!

My windows form has Splitter control on it, and I save splitter's last
X-location when user changes it like ...

Private Sub Splitter1_SplitterMoved(ByVal sender As Object, ByVal e As
System.Windows.Forms.SplitterEventArgs) Handles Splitter1.SplitterMoved
'// Saving new Splitter X-Location
oSettings.SaveSetting(Application.ProductName, Me.Name,
"SplitterLocationX", Splitter1.Location.X.ToString())
End Sub

.... and this is working fine so far.


But when user opens this form I want my application to set splitter
X-location to this saved position again, and I tried like this way ...

Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles MyBase.Load
Try
'// Retrieving last Splitter X-Location
Dim intX As Integer =
Convert.ToInt32(oSettings.GetSetting(Application.ProductName, Me.Name,
"SplitterLocationX", 160))
Splitter1.Location = New Point(intX, Splitter1.Location.Y)

Catch ex As Exception
MessageBox.Show(ex.Message, "Error (Form1.Load)",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub

.... but it's not moving to this retrieved X-location value :( What wrong
with this?

Anyway 'intX'-integer variable contains correct saved value (160 is only
default value if 'intX'-integer variable is not saved yet).
 
H

Herfried K. Wagner [MVP]

* "Mika M said:
My windows form has Splitter control on it, and I save splitter's last
X-location when user changes it like ...

Private Sub Splitter1_SplitterMoved(ByVal sender As Object, ByVal e As
System.Windows.Forms.SplitterEventArgs) Handles Splitter1.SplitterMoved
'// Saving new Splitter X-Location
oSettings.SaveSetting(Application.ProductName, Me.Name,
"SplitterLocationX", Splitter1.Location.X.ToString())
End Sub

... and this is working fine so far.


But when user opens this form I want my application to set splitter
X-location to this saved position again, and I tried like this way ...

Have a look at the splitter's 'SplitPosition' property!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top