|
-
Jul 16th, 2007, 05:34 AM
#1
Thread Starter
New Member
[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.
-
Jul 16th, 2007, 05:59 AM
#2
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
-
Jul 16th, 2007, 09:55 AM
#3
Thread Starter
New Member
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
-
Jul 16th, 2007, 09:56 AM
#4
Re: [2005] Listview help
 Originally Posted by wanderer17
and isnt there one command that i can use to clear everything out?
ListView1.Items.Clear
-
Jul 16th, 2007, 10:16 AM
#5
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:
' Clear the text boxes directly on the form.
For Each ctl As Control In Me.Controls
If TypeOf ctl Is TextBox Then
ctl.Text = String.Empty
End If
Next ctl
-
Jul 17th, 2007, 01:38 AM
#6
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.
-
Jul 17th, 2007, 06:32 AM
#7
Thread Starter
New Member
Re: [2005] Listview help
Thank you all for replying
-
Jul 17th, 2007, 06:48 AM
#8
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.
-
Jul 17th, 2007, 07:37 AM
#9
Thread Starter
New Member
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
-
Jul 17th, 2007, 07:57 AM
#10
Re: [2005] Listview help
My friend you must select a row first (and have 1-2-3 columns,right )
-
Jul 17th, 2007, 12:10 PM
#11
Thread Starter
New Member
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
-
Jul 18th, 2007, 02:19 AM
#12
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|