Sample: Saving and Resoring Layout using String in VB.Net

May 3, 2010 at 3:47 PM
Edited May 3, 2010 at 3:49 PM
Class MainWindow ' Saves and restores to a String; My.Settings.DockLayout. Private Sub dockManager_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles dockManager.Loaded Dim sr As New IO.StringReader(My.Settings.DockLayout) dockManager.RestoreLayout(sr) sr.Close() End Sub Private Sub MainWindow_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.Closing Dim sb As New Text.StringBuilder Dim sw As New IO.StringWriter(sb) dockManager.SaveLayout(sw) sw.Close() Debug.WriteLine(sb.ToString) My.Settings.DockLayout = sb.ToString My.Settings.Save() End Sub End Class