04-17-2014, 11:28 AM
I have a little problem that I can't seem to solve.
When I try to add a value (integer) to a generic list (of integer), I always get a NullReferenceException.
This is my code:
[code2=vbnet]Dim listIndexes As List(Of Integer) = Nothing
For Each i As ListViewItem In Me.listKeys.Items
For Each i2 As ListViewItem In Me.listKeys.Items
If i.Text = i2.Text Then
listIndexes.Add(i.Index) 'The error persists here: NullReferenceException
listIndexes.Add(i2.Index) 'and propably an error here too
End If
Next
Next
Me.SelectKeys(listIndexes) 'This line just selects the items in the listview[/code2]
I've discovered that the index of these two items in the listview are both zero.
Hope someone can help,
brco
When I try to add a value (integer) to a generic list (of integer), I always get a NullReferenceException.
This is my code:
[code2=vbnet]Dim listIndexes As List(Of Integer) = Nothing
For Each i As ListViewItem In Me.listKeys.Items
For Each i2 As ListViewItem In Me.listKeys.Items
If i.Text = i2.Text Then
listIndexes.Add(i.Index) 'The error persists here: NullReferenceException
listIndexes.Add(i2.Index) 'and propably an error here too
End If
Next
Next
Me.SelectKeys(listIndexes) 'This line just selects the items in the listview[/code2]
I've discovered that the index of these two items in the listview are both zero.
Hope someone can help,
brco