Results 1 to 12 of 12

Thread: [2005] Listview help

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    7

    [2005] Listview help

    Hi i am a beginner

    I hope you can help me.

    1. I am using a listview with three columns (column1 =name, column2=carpetneeded, column3=costcarpet) in the properties i have chosen to select the whole row
    when i have selected a whole row i want to get the item value (eg 54) which i have selected in column 2 to be calculated with something like the value in a textbox.

    what command would i use

    eg calculation

    textbox1.Text = Val(textbox1.Text) - (selected item in the column)

    i hope you understand what i mean


    2. Could you please tell me i have a form and a want to make a button which will clear out everything in the form eg textboxes, listview, as if the form had just started

    3. The other thing is could you tell me if i have a form open how could i open another one, so i have two forms opened at the same time.

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [2005] Listview help

    For the first question you need something like this:
    1 ListView1.SelectedItems(0).SubItems(2).Text
    2 make a button and clear every item you like in it's click event
    3 dim f as new formX
    f.show

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    7

    Re: [2005] Listview help

    thanks for your reply sapator when you say do this ListView1.SelectedItems(0).SubItems(2).Text what does the 0 and subitems(2) stand for ?

    and isnt there one command that i can use to clear everything out?

    thank you

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2005] Listview help

    Quote Originally Posted by wanderer17
    and isnt there one command that i can use to clear everything out?
    ListView1.Items.Clear

  5. #5
    Registered User nmadd's Avatar
    Join Date
    Jun 2007
    Location
    U.S.A.
    Posts
    1,676

    Re: [2005] Listview help

    Regarding clearing the TextBoxes on your form as you mentioned, you can do something like this for the controls that are directly on your form.

    vb.net Code:
    1. ' Clear the text boxes directly on the form.
    2.         For Each ctl As Control In Me.Controls
    3.             If TypeOf ctl Is TextBox Then
    4.                 ctl.Text = String.Empty
    5.             End If
    6.         Next ctl

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [2005] Listview help

    Hi.
    ListView1.SelectedItems(0).SubItems(2).Text
    means that you get the first item of the selected ones (the row you select actually) and the 2nds subitem (aka 3rd column) text.

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    7

    Re: [2005] Listview help

    Thank you all for replying

  8. #8
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2005] Listview help

    If you consider this resolved, you could help us out by pulling down the Thread Tools menu and clicking the Mark Thread Resolved menu item. That will let everyone know that you have your answer.

    Thank you.

  9. #9

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    7

    Re: [2005] Listview help

    hi

    i tryed what sapator said but i get an error saying invalid arguement=value0 is not valid for index what does that mean?

    thanks

  10. #10
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [2005] Listview help

    My friend you must select a row first (and have 1-2-3 columns,right )

  11. #11

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    7

    Re: [2005] Listview help

    hi yes 3 columns but under properties i have chose to select all 3 at once, and when i select it and press a button it removes 2-3 items then it gives the above error this is the coding i am using.

    For Each lvItem As ListViewItem In ListView2.SelectedItems
    ListView2.Items.Remove(lvItem)

    totalcostcarpetlabel.Text = Val(totalcostcarpetlabel.Text) - ListView2.SelectedItems(0).SubItems(3).Text
    totalareacarpetlabel.Text = Val(totalareacarpetlabel.Text) - ListView2.SelectedItems(0).SubItems(2).Text
    Next lvItem

    i want to use the values in column 2 and 3

    i hope you can help

    thanks

  12. #12
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [2005] Listview help

    You don't have to remove them.
    Just select the one you want ListView2.SelectedItems(0)
    or ListView2.SelectedItems(1) or ListView2.SelectedItems(2).
    BTW doing this
    For Each lvItem As ListViewItem In ListView2.SelectedItems
    ListView2.Items.Remove(lvItem)
    you remove ALL of your items so you get the error.

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