Results 1 to 8 of 8

Thread: Getting numbers from listview

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    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:
    1. For i = 0 To listviewNumbers.Items.Count
    2.  
    3. '// Perform operations on number then delete it.
    4.  
    5. 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

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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))
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    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

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: Getting numbers from listview

    Does that mean when you added them you did not give them a name?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    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

  7. #7
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    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
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2009
    Location
    Scotland
    Posts
    417

    Re: Getting numbers from listview

    Thanks mate

    Graham

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width