J. Scott Elblein
Well-known member
Hey all,
Haven't been doing a thing in VB.net in almost a year now and I'm surprisingly rusty. I'm just trying to move the selected item in a listview to the next one when a user clicks a "Next" button, using the code below. But once it gets to this line:
Me.lvFriendIDs.Items(strItem).Selected = True
I get a: Object reference not set to an instance of an object, error. I remember that was one thing about VB.net is it's not always intuitive. For instance, wouldn't using the code "Me.lvFriendIDs" be referencing the object that already exists? Anyway, can someone point out what is wrong for me and refresh my rusty .NET skills? lol.
Thanks
Haven't been doing a thing in VB.net in almost a year now and I'm surprisingly rusty. I'm just trying to move the selected item in a listview to the next one when a user clicks a "Next" button, using the code below. But once it gets to this line:
Me.lvFriendIDs.Items(strItem).Selected = True
I get a: Object reference not set to an instance of an object, error. I remember that was one thing about VB.net is it's not always intuitive. For instance, wouldn't using the code "Me.lvFriendIDs" be referencing the object that already exists? Anyway, can someone point out what is wrong for me and refresh my rusty .NET skills? lol.
Thanks
VB.NET:
Dim strItem As String = Me.lvFriendIDs.SelectedIndices.Item(0)
Dim strFriendID As String = Me.lvFriendIDs.Items.Item(Me.lvFriendIDs.SelectedIndices.Item(0)).SubItems(0).Text
strItem += 1
Me.lvFriendIDs.Items(strItem).Selected = True
Me.lvFriendIDs.Items(strItem).EnsureVisible()
Me.lvFriendIDs.Select()