Z
Zarko Ursic
Hi,
I try to set programmatically treeview checkboxes. Basically the user choses
a configuration from a dropdownlist that triggers a database query returning
the required IDs of the treeview elements that have to be checked.
The following code is triggered when an item is chosen from a dropdownlist:
(dr is the returned datareader containing "ID" and "label", the treeview is
3 levels deep)
Dim i, j, k As Integer
If dr.HasRows Then
Do While dr.Read()
For i = 0 To tvFilters.Nodes.Count - 1
For j = 0 To tvFilters.Nodes(i).Nodes.Count - 1
If tvFilters.Nodes(i).Nodes.Item(j).ID = dr.GetInt32(0) Then
tvFilters.Nodes(i).Nodes.Item(j).Checked = True
Else
tvFilters.Nodes(i).Nodes.Item(j).Checked = False
End If
For k = 0 To tvFilters.Nodes(i).Nodes.Item(j).Nodes.Count - 1
If tvFilters.Nodes(i).Nodes.Item(j).Nodes.Item(k).ID =
dr.GetInt32(0) Then
tvFilters.Nodes(i).Nodes.Item(j).Nodes.Item(k).Checked =
True
Else
tvFilters.Nodes(i).Nodes.Item(j).Nodes.Item(k).Checked =
False
End If
Next
Next
Next
Loop
End If
All needed values go correctly through the test but when the test is
successfull, the previous checked item is automatically set to False! Only
the last value remains True and my tree has only one item checked!
Which kind of event can modify my checked value during the execution of this
piece of code?
Thanks in advance,
Zarko
I try to set programmatically treeview checkboxes. Basically the user choses
a configuration from a dropdownlist that triggers a database query returning
the required IDs of the treeview elements that have to be checked.
The following code is triggered when an item is chosen from a dropdownlist:
(dr is the returned datareader containing "ID" and "label", the treeview is
3 levels deep)
Dim i, j, k As Integer
If dr.HasRows Then
Do While dr.Read()
For i = 0 To tvFilters.Nodes.Count - 1
For j = 0 To tvFilters.Nodes(i).Nodes.Count - 1
If tvFilters.Nodes(i).Nodes.Item(j).ID = dr.GetInt32(0) Then
tvFilters.Nodes(i).Nodes.Item(j).Checked = True
Else
tvFilters.Nodes(i).Nodes.Item(j).Checked = False
End If
For k = 0 To tvFilters.Nodes(i).Nodes.Item(j).Nodes.Count - 1
If tvFilters.Nodes(i).Nodes.Item(j).Nodes.Item(k).ID =
dr.GetInt32(0) Then
tvFilters.Nodes(i).Nodes.Item(j).Nodes.Item(k).Checked =
True
Else
tvFilters.Nodes(i).Nodes.Item(j).Nodes.Item(k).Checked =
False
End If
Next
Next
Next
Loop
End If
All needed values go correctly through the test but when the test is
successfull, the previous checked item is automatically set to False! Only
the last value remains True and my tree has only one item checked!
Which kind of event can modify my checked value during the execution of this
piece of code?
Thanks in advance,
Zarko