I'm new to .net so go easy on my. I have a treeview that is re-populated when different radio buttons are clicked.
I'm using ADO.net to get the data from SQL. I'm trying to save a string into the Tag of the treeview.node, but keep getting this error when I try to re-populate the Tag.
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values
Here is the code:
Do I need to clear the Tag?
What am I missing?
What doesn't kill you makes you stronger.
I'm using ADO.net to get the data from SQL. I'm trying to save a string into the Tag of the treeview.node, but keep getting this error when I try to re-populate the Tag.
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll
Additional information: Specified argument was out of the range of valid values
Here is the code:
Code:
Dim l As Integer = A.Tables("Field").Rows.Count - 1
For l = 0 To A.Tables("Field").Rows.Count - 1
TreeView1.Nodes.Add(New TreeNode(A.Tables("Field").Rows(l).Item("Field_English")))
'''Add Child to treeview and Tag
Dim p As Integer = B.Tables("Area").Rows.Count - 1
For p = 0 To B.Tables("Area").Rows.Count - 1
If A.Tables("Field").Rows(l).Item("Field_Code") = B.Tables("Area").Rows(p).Item("Field_Code") Then
TreeView1.Nodes(l).Nodes.Add(New TreeNode(B.Tables("Area").Rows(p).Item("Field_Area_Code") & " " & B.Tables("Area").Rows(p).Item("Field_Area_English")))
''Errors here [COLOR=blue] TreeView1.Nodes(l).Nodes(p).Tag = B.Tables("Area").Rows(p).Item("Field_Code") & "-" & B.Tables("Area").Rows(p).Item("Field_Area_Code")[/color]
End If
Next
Next
Do I need to clear the Tag?
What am I missing?
What doesn't kill you makes you stronger.