Results 1 to 4 of 4

Thread: list view question/problem **** Resolved *******

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Location
    East
    Posts
    8

    list view question/problem **** Resolved *******

    Hello I have a Form that has a bunch of controls a couple of textboxes, comboboxes and some cmd buttons with a listview
    now what I am doing is gathering some user data via text boxes and combobox and I am giving the user the ability to add and remove these records into the list view only problem is one of those fields is a decimal field and I need to keep track of that number (that is not the problem) my problem is when the user
    removes an item from the listview. I need to get the selected items .subitem and add it back to my running total I know you can go in and get the selected items from the listview however I just need the .subitems


    Thanks
    Last edited by vbnet20; Jul 8th, 2003 at 01:19 PM.

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    Reading, UK
    Posts
    870
    Dim lstItems As New ListViewItem()

    lstItems = ListView1.SelectedItems(0)
    MsgBox(lstItems.SubItems(0).Text)
    MsgBox(lstItems.SubItems(1).Text)
    www.vb-tech.com
    .Net Freelance Development
    http://weblog.vb-tech.com/nick
    My blog

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Location
    East
    Posts
    8

    Okay listview Error specified arg was out of range of valid values

    Here is the code

    Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delete.Click
    Dim a As Integer
    Dim lstItems As New ListViewItem()
    For a = ListView1.Items.Count - 1 To 1 Step -1
    If ListView1.Items(a).Checked = True Then
    ListView1.Items.RemoveAt(a)
    '
    lstItems = ListView1.SelectedItems(a)
    MsgBox(lstItems.SubItems(0).Text)
    MsgBox(lstItems.SubItems(1).Text)

    End If
    Next
    AddItem.Enabled = True
    ListView1.Enabled = True
    tempmoney = 0
    labelcapture = tempmoney + Val(Label12.Text)
    AddItem.Enabled = True
    cboAcctNum.Focus()
    End Sub



    Thanks
    Last edited by vbnet20; Jul 8th, 2003 at 01:19 PM.

  4. #4

    Thread Starter
    New Member
    Join Date
    Apr 2003
    Location
    East
    Posts
    8

    figured it out Thanks

    modified code


    Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delete.Click
    Dim a As Integer
    Dim lstItems As New ListViewItem()
    For a = ListView1.Items.Count - 1 To 1 Step -1
    If ListView1.Items(a).Checked = True Then
    lstItems = ListView1.Items(a)
    ListView1.Items.RemoveAt(a)
    MsgBox(lstItems.SubItems(0).Text)
    MsgBox(lstItems.SubItems(1).Text)
    End If
    Next
    AddItem.Enabled = True
    ListView1.Enabled = True
    tempmoney = 0
    labelcapture = tempmoney + Val(Label12.Text)
    AddItem.Enabled = True
    cboAcctNum.Focus()
    End Sub

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