C
Co
Hi All,
As a follow up of my previous question concerning calling functions
from another form I created this:
Public Class TreeViewState
Inherits Explorer1
Private tt As New Dictionary(Of String, Boolean)
Public Sub RestoreTreeViewExpandedState()
Dim i As Integer
For i = 0 To TreeView.Nodes.Count - 1
If tt.ContainsKey(TreeView.Nodes(i).Name) Then
If tt(TreeView.Nodes(i).Name) Then
TreeView.Nodes(i).Expand()
Else
TreeView.Nodes(i).Collapse()
End If
End If
Next
End Sub
Public Function SaveTreeState()
Dim i As Integer
For i = 0 To TreeView.Nodes.Count - 1
If TreeView.Nodes(i).Nodes.Count > 0 Then
tt.Add(TreeView.Nodes(i).Name, TreeView.Nodes
(i).IsExpanded)
End If
Next
Return tt
End Function
End Class
This class will save the status of the treeview on form Explorer1.
I want to call the functions in this class from another form,
frmZoeken:
Dim currentState As TreeViewState
currentState.SaveTreeState()
SaveQueryInTreeview()
currentUser.RestoreTreeViewExpandedState()
I get an error when I try this obect reference not set to an instance
of an object
Marco.
As a follow up of my previous question concerning calling functions
from another form I created this:
Public Class TreeViewState
Inherits Explorer1
Private tt As New Dictionary(Of String, Boolean)
Public Sub RestoreTreeViewExpandedState()
Dim i As Integer
For i = 0 To TreeView.Nodes.Count - 1
If tt.ContainsKey(TreeView.Nodes(i).Name) Then
If tt(TreeView.Nodes(i).Name) Then
TreeView.Nodes(i).Expand()
Else
TreeView.Nodes(i).Collapse()
End If
End If
Next
End Sub
Public Function SaveTreeState()
Dim i As Integer
For i = 0 To TreeView.Nodes.Count - 1
If TreeView.Nodes(i).Nodes.Count > 0 Then
tt.Add(TreeView.Nodes(i).Name, TreeView.Nodes
(i).IsExpanded)
End If
Next
Return tt
End Function
End Class
This class will save the status of the treeview on form Explorer1.
I want to call the functions in this class from another form,
frmZoeken:
Dim currentState As TreeViewState
currentState.SaveTreeState()
SaveQueryInTreeview()
currentUser.RestoreTreeViewExpandedState()
I get an error when I try this obect reference not set to an instance
of an object
Marco.