Hello all,
I have a situation where I'm trying to set the Checked property of node(s) in a treeview control based on a list of items from an array. This array holds prior selected/checked items from the treeview in a previous process.
When the user returns to view the treeview in another process run (maybe three days later), I want to set/check those items in the treeview (that were previously picked by the user) during the form_load event before the treeview and program are available to the user.
During the form_load event, I call the following routine with expectation that these previously selected items will show up in a Checked state.
===========================================
Private Sub CheckThisOut()
'pre-Check cokeys found in EEManualQACokeyList table
Dim i As Integer
Dim strTemp As String
Dim intLoop As Integer
Dim lngFound As Long
lngFound = 1
60 If UBound(mstrSelectedCokeys()) > 0 Then
For intLoop = 0 To UBound(mstrSelectedCokeys())
strTemp = mstrSelectedCokeys(intLoop)
'loop through each node finding the selected cokeys chosen
With TreeView1
For i = 1 To .Nodes.Count - 1
If .Nodes(i).Text Like "*" & strTemp & "*" Then
'set the checkbox in this node
.Nodes(i).Checked = True
' .Nodes(i).BackColor = vbButtonFace
.Nodes(i).EnsureVisible
.Nodes(i).Selected = True
DoEvents
'hang on to the first location checked
If lngFound = 1 Then lngFound = .Nodes(i).Index
Exit For
End If
Next i
End With
Next intLoop
TreeView1.Refresh
DoEvents
End If
mlngFirstSelCokey = lngFound
End Sub
==============================================
I tried setting another property (BackColor) as a test to make sure that the node is actually being edited and that works. But when I simply try to set .Checked = True, the checkbox on that node does not show up with a checkmark on it.
Is there another event that kicks off from the Checked property that prevents the checkmark from showing? Am I missing other calls that need to be made for the Checked property so that it will stick?
Thanks for any help,
gregoriw
I have a situation where I'm trying to set the Checked property of node(s) in a treeview control based on a list of items from an array. This array holds prior selected/checked items from the treeview in a previous process.
When the user returns to view the treeview in another process run (maybe three days later), I want to set/check those items in the treeview (that were previously picked by the user) during the form_load event before the treeview and program are available to the user.
During the form_load event, I call the following routine with expectation that these previously selected items will show up in a Checked state.
===========================================
Private Sub CheckThisOut()
'pre-Check cokeys found in EEManualQACokeyList table
Dim i As Integer
Dim strTemp As String
Dim intLoop As Integer
Dim lngFound As Long
lngFound = 1
60 If UBound(mstrSelectedCokeys()) > 0 Then
For intLoop = 0 To UBound(mstrSelectedCokeys())
strTemp = mstrSelectedCokeys(intLoop)
'loop through each node finding the selected cokeys chosen
With TreeView1
For i = 1 To .Nodes.Count - 1
If .Nodes(i).Text Like "*" & strTemp & "*" Then
'set the checkbox in this node
.Nodes(i).Checked = True
' .Nodes(i).BackColor = vbButtonFace
.Nodes(i).EnsureVisible
.Nodes(i).Selected = True
DoEvents
'hang on to the first location checked
If lngFound = 1 Then lngFound = .Nodes(i).Index
Exit For
End If
Next i
End With
Next intLoop
TreeView1.Refresh
DoEvents
End If
mlngFirstSelCokey = lngFound
End Sub
==============================================
I tried setting another property (BackColor) as a test to make sure that the node is actually being edited and that works. But when I simply try to set .Checked = True, the checkbox on that node does not show up with a checkmark on it.
Is there another event that kicks off from the Checked property that prevents the checkmark from showing? Am I missing other calls that need to be made for the Checked property so that it will stick?
Thanks for any help,
gregoriw