Getting numbers from listview
Hi Guys,
In my application i store number in a list box, the number of numbers vary depending on the user, normally 20 - 100, i have this code setup:
vb.net Code:
For i = 0 To listviewNumbers.Items.Count
'// Perform operations on number then delete it.
Next
So when i retrieve a digit from the listview, i was going to use it, then delete it from the listview (so it wouldn't be used again)
I am having trouble getting the number from the listview to use, i can do listviewHarvestedIDs.SelectedItems(0).Text but that means the user has to select every number to use, i really need to select a numberautomatically (doesn't need to be in order) use it then delete.
any help would be appreciated
thanks guys
Graham
Re: Getting numbers from listview
Code:
'simple test
ListView1.Items.Clear()
For x = 0 To 199
ListView1.Items.Add(x.ToString)
ListView1.Items(x).Name = x.ToString
Next
ListView1.Items.RemoveByKey("13")
ListBox or ListView?
Re: Getting numbers from listview
Code:
'simple test
ListView1.Items.Clear()
ListBox1.Items.Clear()
For x = 0 To 199
ListView1.Items.Add(x.ToString)
ListView1.Items(x).Name = x.ToString
ListBox1.Items.Add(x)
Next
ListView1.Items.RemoveByKey("13")
ListBox1.Items.RemoveAt(ListBox1.Items.IndexOf(13))
Re: Getting numbers from listview
Hi Mate,
Thanks for the reply, it's a listview.
The numbers are already added to the listview, what i was trying to do is when a button is pressed, i begin to grab the numbers one at a time from the listview, perform an action with them, then delete that number from the listview untill there are no numbers left, then stop the program.
thaqnks mate
Graham
Re: Getting numbers from listview
Does that mean when you added them you did not give them a name?
Re: Getting numbers from listview
Hi Mate,
Yeah, basically they are a load of random digits like:
14543
56432
75433
i was going to grab one, one at a time then use and delete :)
Graham
Re: Getting numbers from listview
Without a key (.Name) then
Code:
For x As Integer = 0 To ListView1.Items.Count
If ListView1.Items(x).Text = "14" Then Stop
Next
Re: Getting numbers from listview