Smokeywade
Member
- Joined
- Sep 11, 2007
- Messages
- 22
- Programming Experience
- 3-5
I have a treelistview that is populated with parent child. What I'm trying to do is when the user clicks on the parent place the subitems text into a textbox
Which works fine when I click on a parent, But when I click on the first record child I get error Object Reference not set to an instance of an object.
when I click on the second record child I get specified argument was out of range the valid values parmeter name: Index was out of range. Must be non-negative and less then the size of the collection.
Here is the simple code that dont work
Private Sub treeListView1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles treeListView1.Click
Any Ideas on how I will tell it - if child rec do nothing.
Thanks
Thank You
VB.NET:
TextBox1.Text = treeListView1.SelectedNodes(0).SubItems(4).Text & ""
when I click on the second record child I get specified argument was out of range the valid values parmeter name: Index was out of range. Must be non-negative and less then the size of the collection.
Here is the simple code that dont work
Private Sub treeListView1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles treeListView1.Click
VB.NET:
Try
If treeListView1.SelectedNodes(0).SubItems(4).Text Is DBNull.Value Then
TextBox1.Text = ""
Else
TextBox1.Text = treeListView1.SelectedNodes(0).SubItems(4).Text & ""
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Any Ideas on how I will tell it - if child rec do nothing.
Thanks
Thank You