Hi all,
How can I get the value stored from the selected item and subitems of a
listview?
Thanks in advance,
George 6 22043
George,
Here is one way to get the first selected item:
Dim item As ListViewItem
If lvwInvoice.SelectedItems.Count > 0 Then
item = lvwInvoice.SelectedItems(0)
MsgBox(item.Text)
MsgBox(item.SubItems(1).Text)
End If
"George" wrote: Hi all,
How can I get the value stored from the selected item and subitems of a listview?
Thanks in advance,
George
Thanks for that - it is straight to the point!
I used the example, and it worked - sort of. The first time I clicked on an
item, it returned the values fine. But when I clicked on another item I got
the following error:
InvalidArgument=Value of '0' is not valid for 'index'.
This is the code:
Dim item = lvCollection.SelectedItems(0)
cmbCond.Text = item.Text
txtQty.Text = item.SubItems(1).Text
It works the first time, but not the second?
Thanks in advance,
George
"Kerry Moorman" wrote: George,
Here is one way to get the first selected item:
Dim item As ListViewItem If lvwInvoice.SelectedItems.Count > 0 Then item = lvwInvoice.SelectedItems(0) MsgBox(item.Text) MsgBox(item.SubItems(1).Text) End If "George" wrote:
Hi all,
How can I get the value stored from the selected item and subitems of a listview?
Thanks in advance,
George
George,
Are you using an IF statement to make sure that an item is selected, like I
did in my original example?
If you are writing your code in the listview's SelectedIndexChanged event,
when you select a second item, the first item is de-selected and the
SelectedIndexChanged event fires. At that point there is no SelectedItems(0).
Kerry Moorman
"George" wrote: Thanks for that - it is straight to the point!
I used the example, and it worked - sort of. The first time I clicked on an item, it returned the values fine. But when I clicked on another item I got the following error:
InvalidArgument=Value of '0' is not valid for 'index'.
This is the code:
Dim item = lvCollection.SelectedItems(0) cmbCond.Text = item.Text txtQty.Text = item.SubItems(1).Text
It works the first time, but not the second?
Thanks in advance,
George
"Kerry Moorman" wrote:
George,
Here is one way to get the first selected item:
Dim item As ListViewItem If lvwInvoice.SelectedItems.Count > 0 Then item = lvwInvoice.SelectedItems(0) MsgBox(item.Text) MsgBox(item.SubItems(1).Text) End If "George" wrote:
Hi all,
How can I get the value stored from the selected item and subitems of a listview?
Thanks in advance,
George
I guess that is what I am having a hard time understanding....how can I get
the selected item?
Currently, I am using the SelectedIndexChanged event. Is the
SelectedIndexChanged event the correct way to go and if so how do I get the
item and any other item clicked?
"Kerry Moorman" wrote: George,
Are you using an IF statement to make sure that an item is selected, like I did in my original example?
If you are writing your code in the listview's SelectedIndexChanged event, when you select a second item, the first item is de-selected and the SelectedIndexChanged event fires. At that point there is no SelectedItems(0).
Kerry Moorman
"George" wrote:
Thanks for that - it is straight to the point!
I used the example, and it worked - sort of. The first time I clicked on an item, it returned the values fine. But when I clicked on another item I got the following error:
InvalidArgument=Value of '0' is not valid for 'index'.
This is the code:
Dim item = lvCollection.SelectedItems(0) cmbCond.Text = item.Text txtQty.Text = item.SubItems(1).Text
It works the first time, but not the second?
Thanks in advance,
George
"Kerry Moorman" wrote:
George,
Here is one way to get the first selected item:
Dim item As ListViewItem If lvwInvoice.SelectedItems.Count > 0 Then item = lvwInvoice.SelectedItems(0) MsgBox(item.Text) MsgBox(item.SubItems(1).Text) End If "George" wrote:
> Hi all, > > How can I get the value stored from the selected item and subitems of a > listview? > > Thanks in advance, > > George
I was able to get to the following:
Dim itemall As ListView.SelectedListViewItemCollection =
lvCollection.SelectedItems
Dim item As ListViewItem
For Each item In itemall
cmbCond.Text = item.Text
txtQty.Text = item.SubItems(1).Text
cmbLocation.Text = item.SubItems(2).Text
txtColComment.Text = item.SubItems(3).Text
Next
But it seems a bit overdone, since my listview is not multi select. Is
there a more straightforward way to get what was selected?
George
"Kerry Moorman" wrote: George,
Are you using an IF statement to make sure that an item is selected, like I did in my original example?
If you are writing your code in the listview's SelectedIndexChanged event, when you select a second item, the first item is de-selected and the SelectedIndexChanged event fires. At that point there is no SelectedItems(0).
Kerry Moorman
"George" wrote:
Thanks for that - it is straight to the point!
I used the example, and it worked - sort of. The first time I clicked on an item, it returned the values fine. But when I clicked on another item I got the following error:
InvalidArgument=Value of '0' is not valid for 'index'.
This is the code:
Dim item = lvCollection.SelectedItems(0) cmbCond.Text = item.Text txtQty.Text = item.SubItems(1).Text
It works the first time, but not the second?
Thanks in advance,
George
"Kerry Moorman" wrote:
George,
Here is one way to get the first selected item:
Dim item As ListViewItem If lvwInvoice.SelectedItems.Count > 0 Then item = lvwInvoice.SelectedItems(0) MsgBox(item.Text) MsgBox(item.SubItems(1).Text) End If "George" wrote:
> Hi all, > > How can I get the value stored from the selected item and subitems of a > listview? > > Thanks in advance, > > George
George,
Something like this:
Dim item as ListviewItem
If lvCollection.SelectedItems > 0 Then
item = lvCollection.SelectedItems(0)
cmbCond.Text = item.Text
txtQty.Text = item.SubItems(1).Text
cmbLocation.Text = item.SubItems(2).Text
txtColComment.Text = item.SubItems(3).Text
End If
Kerry Moorman
"George" wrote: I was able to get to the following:
Dim itemall As ListView.SelectedListViewItemCollection = lvCollection.SelectedItems Dim item As ListViewItem For Each item In itemall cmbCond.Text = item.Text txtQty.Text = item.SubItems(1).Text cmbLocation.Text = item.SubItems(2).Text txtColComment.Text = item.SubItems(3).Text Next
But it seems a bit overdone, since my listview is not multi select. Is there a more straightforward way to get what was selected?
George "Kerry Moorman" wrote:
George,
Are you using an IF statement to make sure that an item is selected, like I did in my original example?
If you are writing your code in the listview's SelectedIndexChanged event, when you select a second item, the first item is de-selected and the SelectedIndexChanged event fires. At that point there is no SelectedItems(0).
Kerry Moorman
"George" wrote:
Thanks for that - it is straight to the point!
I used the example, and it worked - sort of. The first time I clicked on an item, it returned the values fine. But when I clicked on another item I got the following error:
InvalidArgument=Value of '0' is not valid for 'index'.
This is the code:
Dim item = lvCollection.SelectedItems(0) cmbCond.Text = item.Text txtQty.Text = item.SubItems(1).Text
It works the first time, but not the second?
Thanks in advance,
George
"Kerry Moorman" wrote:
> George, > > Here is one way to get the first selected item: > > Dim item As ListViewItem > If lvwInvoice.SelectedItems.Count > 0 Then > item = lvwInvoice.SelectedItems(0) > MsgBox(item.Text) > MsgBox(item.SubItems(1).Text) > End If > > > > "George" wrote: > > > Hi all, > > > > How can I get the value stored from the selected item and subitems of a > > listview? > > > > Thanks in advance, > > > > George
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Phil Watkins |
last post by:
I am a novice programer in Vb and I am having a major
brain ache finding out which item has been selected within
a list view and then either deleting that item or editing
them. My searching so...
|
by: Sam Johnson |
last post by:
H
how can I SET the selected item in a listview control
Thank
Sam
|
by: Steve |
last post by:
I can't seem to get howto find the index of the selected item in a listview
(View.Details)....
Thanks in advance,
steve
|
by: =?Utf-8?B?TmFjaA==?= |
last post by:
It works on the first selection when I want to get a different selection I get
InvalidArgument=Value of '0' is not valid for 'index'.
Parameter name: index
The Following is the code
Private...
|
by: Bill-R |
last post by:
I'm trying to convert a vb6 program to vb.net (vb2008 express)
I have text data in a Listview Control
I use a Textbox to enter characters to search the Listview
When a Match is found, I use...
|
by: gubbachchi |
last post by:
Hi,
How can I get the selected item of the drop down box into a php variable in the same page. The options in drop down box are A,B and C and the code is here
<select>
<option value="Item...
|
by: lotus18 |
last post by:
Hello World
It's me again. LOL, I know how to get the selected item on the second column of a listview.
frmCourses.lvwCourses.SelectedItem().SubItems(2)
But I don't know how to do it with...
|
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= |
last post by:
I have a listview that when I select an item, it populates a details view. I
want to show the item that was selected in the listview by changing it to
yellow. Trouble is, the selected item does not...
|
by: luiggye |
last post by:
Hi
I have a LISTVIEW where every item have 6 subitems (columns).
lstBrowse.Columns.Add("Col1", 150, HorizontalAlignment.Left)
lstBrowse.Columns.Add("Col2", 150, HorizontalAlignment.Left)...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |