|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Treeview windowstate save and restoreI have this Treeview of which I want to save the window status when I'm doing some action with the nodes. After the action I want to restore the windowstate. I save the windowstate in a Dictionary. The code I have does work except that it doesn't expand the nodes under the root node. All nodes under there are collapsed or expanded the way I saved them. What do I need to also save the expand or collapse for the nodes under the root node? Private tt As New Dictionary(Of String, Boolean) Public Sub SaveTreeView(ByVal treeview As TreeView) For Each node As TreeNode In treeview.Nodes SaveTreeState(node) Next End Sub Public Sub RestoreTreeView(ByVal treeview As TreeView) For Each node As TreeNode In treeview.Nodes RestoreTreeViewExpandedState(node) Next End Sub Private Sub RestoreTreeViewExpandedState(ByVal objTreeNode _ As TreeNode) Dim objChildTreeNode As Node For Each objChildTreeNode In objTreeNode.Nodes Dim ID As String = objChildTreeNode.row("ID").ToString RestoreTreeViewExpandedState(objChildTreeNode) If tt.ContainsKey(ID) Then If tt(ID) Then objChildTreeNode.Expand() Else objChildTreeNode.Collapse() End If End If Next End Sub Private Function SaveTreeState(ByVal objTreeNode _ As TreeNode) As Dictionary(Of String, Boolean) Dim objChildTreeNode As Node For Each objChildTreeNode In objTreeNode.Nodes Dim ID As String = objChildTreeNode.row("ID").ToString SaveTreeState(objChildTreeNode) tt.Add(ID, objChildTreeNode.IsExpanded) Next Return tt End Function Regards Marco The Netherlands See my reply to John some minutes earlier
Cor Show quoteHide quote "Co" <vonclausow***@gmail.com> wrote in message news:895df52b-ccef-4ac2-bca7-a5f52e7e4634@x3g2000yqa.googlegroups.com... > Hi All, > > I have this Treeview of which I want to save the window status when > I'm doing some action with the nodes. > After the action I want to restore the windowstate. > I save the windowstate in a Dictionary. The code I have does work > except that it doesn't expand the nodes > under the root node. All nodes under there are collapsed or expanded > the way I saved them. > > What do I need to also save the expand or collapse for the nodes under > the root node? > > Private tt As New Dictionary(Of String, Boolean) > > Public Sub SaveTreeView(ByVal treeview As TreeView) > > For Each node As TreeNode In treeview.Nodes > SaveTreeState(node) > Next > > End Sub > Public Sub RestoreTreeView(ByVal treeview As TreeView) > > For Each node As TreeNode In treeview.Nodes > RestoreTreeViewExpandedState(node) > Next > > End Sub > Private Sub RestoreTreeViewExpandedState(ByVal objTreeNode _ > As TreeNode) > > Dim objChildTreeNode As Node > > For Each objChildTreeNode In objTreeNode.Nodes > Dim ID As String = objChildTreeNode.row("ID").ToString > RestoreTreeViewExpandedState(objChildTreeNode) > If tt.ContainsKey(ID) Then > If tt(ID) Then > objChildTreeNode.Expand() > Else > objChildTreeNode.Collapse() > End If > End If > > Next > > End Sub > > Private Function SaveTreeState(ByVal objTreeNode _ > As TreeNode) As Dictionary(Of String, Boolean) > > Dim objChildTreeNode As Node > > For Each objChildTreeNode In objTreeNode.Nodes > Dim ID As String = objChildTreeNode.row("ID").ToString > SaveTreeState(objChildTreeNode) > tt.Add(ID, objChildTreeNode.IsExpanded) > Next > > Return tt > End Function > > Regards > Marco > The Netherlands
.NET Security
Equality Test For Objects getting error on record duplication automating ie or webbrowser control VS.NET 2003 to VS.NET 2008 conversion Saving and retrieving WinForm template info Define irregularly shaped area in UserControl where controls may be dropped Selecting dates in SQL Server store the data that is entered in the datagriview Using the Cast Extension Method To Convert To String |
|||||||||||||||||||||||