|
-
Jan 12th, 2008, 07:52 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Listview SelectedIndexes
In my listview this are the values.
1 - Dog - 19
2 - Cat - 2
3 - Shrew - 5
How to retrieve the selectedindex in the listview ? If i select the first record the index must be "0" if the second record then the index is "1" if the third the index is "2". i use this method but it gives me a wrong output.
Code:
Me.Text = Listview1.SelectedIndexes.ToString
The output of that is System.Windows.Form.Listview......
-
Jan 12th, 2008, 07:59 AM
#2
Frenzied Member
Re: [2005] Listview SelectedIndexes
Shouldn't
Me.Text be something like Me.ControlType.text?
-
Jan 12th, 2008, 08:05 AM
#3
Thread Starter
Fanatic Member
Re: [2005] Listview SelectedIndexes
Whether i print it on a textbox, other control and a msgbox ... the output is the same
-
Jan 12th, 2008, 08:09 AM
#4
Frenzied Member
Re: [2005] Listview SelectedIndexes
Code:
txtemailAddress.Text = Me.lsvContacts.SelectedItems(0).SubItems(1).Text
HTH
-
Jan 12th, 2008, 08:19 AM
#5
Thread Starter
Fanatic Member
Re: [2005] Listview SelectedIndexes
but it only retrieve the first record. How about the others ?
-
Jan 12th, 2008, 08:22 AM
#6
Frenzied Member
Re: [2005] Listview SelectedIndexes
Change this SubItems(1) to this SubItems(2), i hope
-
Jan 12th, 2008, 08:22 AM
#7
Thread Starter
Fanatic Member
Re: [2005] Listview SelectedIndexes
I use the ListView_SelectedItemChange So how im gonna use the indexes.
If i use that on a Click event my code and your code would work. But How about on a SelectedItemChanged event ?
-
Jan 12th, 2008, 08:51 AM
#8
Member
Re: [2005] Listview SelectedIndexes
Try this:
VB.NET Code:
Dim index As Integer
index = Me.ListView1.FocusedItem.Index
-
Jan 12th, 2008, 08:53 AM
#9
Member
Re: [2005] Listview SelectedIndexes
this will show a messagebox for each selected item in the listview!
vb Code:
Dim indexes As ListView.SelectedIndexCollection = ListView1.SelectedIndices
Dim index, i As Integer
For Each index In indexes
msgbox(ListView1.Items(index).SubItems(1).Text)
Next
-
Jan 12th, 2008, 08:59 AM
#10
Thread Starter
Fanatic Member
Re: [2005] Listview SelectedIndexes
Thanks toecutter and D4rkness. Now i know the function of the FocusedItem method of a listview thanks again
-
Jan 12th, 2008, 09:02 AM
#11
Thread Starter
Fanatic Member
Re: [2005] Listview SelectedIndexes
Thanks stef-o that was amzing you gave me how to use the selectedindeces im so happy thanks all of you.
-
Jan 12th, 2008, 09:04 AM
#12
Member
Re: [RESOLVED] [2005] Listview SelectedIndexes
No Problem, glad to help.
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
|