473,609 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting the selected listview item

My listview has two columns: Email Address & Email Address Type.

I've figured out how to populate it, but now I'm having trouble figuring out how to properly use the SelectedItems to get at the particular row that is double clicked. Can someone give me an example of how to get at the item, and subitems, of a selected row in a listview?

Thanks,

billy
Nov 20 '05 #1
2 3468
With Deft Fingers, billyb <bi****@discuss ions.microsoft. com> wrote:
My listview has two columns: Email Address & Email Address Type.
I've figured out how to populate it, but now I'm having trouble figuring out how to properly use the SelectedItems to get at the particular row that is double clicked. Can someone give me an example of how to get at the item, and subitems, of a selected row in a listview?


My Code here is used in a "SelectedIndexC hanged" routine... but you should be
able to modify things for your need. My ListView is called "lvModDwgs" . I
had to remove excess 'junk' from my strings (see the INFO lines).

I had my LV "multiselec t" to TRUE... so I can click on more than 1 line. And
the 'first' item per each selected line ends up being 'TmpStrng1' that I list
in a ComboBox (just for info only).
Dim TmpStrng, TmpStrng1 As String
Dim LItem As ListViewItem
Dim LItems As ListView.Select edListViewItemC ollection
LItems = lvModDwgs.Selec tedItems
' INFO - LItem.SubItems( 2).ToString = "ListViewSubIte m: {60-004}"
' Remove ListViewSubItem Gargage!

ComboBox1.Items .Clear()

For Each LItem In LItems

' Remove the Excess Junk from String
TmpStrng = LItem.SubItems( 1).ToString
TmpStrng = Microsoft.Visua lBasic.Right(Tm pStrng, Len(TmpStrng) - 18)
TmpStrng = Microsoft.Visua lBasic.Left(Tmp Strng, Len(TmpStrng) - 1)
txbDwgTab.Text = TmpStrng

' Add Selected Names to ComboBox - Use this to Identify your Selections
TmpStrng1 = LItem.SubItems( 0).ToString
TmpStrng1 = Microsoft.Visua lBasic.Right(Tm pStrng1, Len(TmpStrng1) - 18)
TmpStrng1 = Microsoft.Visua lBasic.Left(Tmp Strng1, Len(TmpStrng1) - 1)
ComboBox1.Items .Add(TmpStrng1)
Next
Regards,

Bruce
Nov 20 '05 #2
Thank you, Bruce! Will implement tonight.

"Mr. B" wrote:
With Deft Fingers, billyb <bi****@discuss ions.microsoft. com> wrote:
My listview has two columns: Email Address & Email Address Type.
I've figured out how to populate it, but now I'm having trouble figuring out how to properly use the SelectedItems to get at the particular row that is double clicked. Can someone give me an example of how to get at the item, and subitems, of a selected row in a listview?


My Code here is used in a "SelectedIndexC hanged" routine... but you should be
able to modify things for your need. My ListView is called "lvModDwgs" . I
had to remove excess 'junk' from my strings (see the INFO lines).

I had my LV "multiselec t" to TRUE... so I can click on more than 1 line. And
the 'first' item per each selected line ends up being 'TmpStrng1' that I list
in a ComboBox (just for info only).
Dim TmpStrng, TmpStrng1 As String
Dim LItem As ListViewItem
Dim LItems As ListView.Select edListViewItemC ollection
LItems = lvModDwgs.Selec tedItems
' INFO - LItem.SubItems( 2).ToString = "ListViewSubIte m: {60-004}"
' Remove ListViewSubItem Gargage!

ComboBox1.Items .Clear()

For Each LItem In LItems

' Remove the Excess Junk from String
TmpStrng = LItem.SubItems( 1).ToString
TmpStrng = Microsoft.Visua lBasic.Right(Tm pStrng, Len(TmpStrng) - 18)
TmpStrng = Microsoft.Visua lBasic.Left(Tmp Strng, Len(TmpStrng) - 1)
txbDwgTab.Text = TmpStrng

' Add Selected Names to ComboBox - Use this to Identify your Selections
TmpStrng1 = LItem.SubItems( 0).ToString
TmpStrng1 = Microsoft.Visua lBasic.Right(Tm pStrng1, Len(TmpStrng1) - 18)
TmpStrng1 = Microsoft.Visua lBasic.Left(Tmp Strng1, Len(TmpStrng1) - 1)
ComboBox1.Items .Add(TmpStrng1)
Next
Regards,

Bruce

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8678
by: Sam Johnson | last post by:
H how can I SET the selected item in a listview control Thank Sam
7
24102
by: GTi | last post by:
I have a listview that with selected items. But I want to "reselect" items after a refresh. Each items have a uniqe value in the Tag object. After a refresh some new items may be added or removed so using item index is not possible. To get the list of selected items I use: ListView.SelectedListViewItemCollection selItems = this.listView1.SelectedItems;
7
34779
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I'v been struggeling with removing selected items from a listview. Anyone that can give me a piece of code that does this? I am a newbee to this C# and cant figure it out.... Regards Martin Arvidsson
2
1624
by: StriderBob | last post by:
In a list box, lbox1.SetSelected(0, True) or lbox1.SelectedIndex = 0 all work fine but how do you set the selected line in a ListView, is it possible? The ListView is being used in Details-View mode, in each line the first item is a line No. (1 - 150 in this instance). I can get an index no for a line I select with the mouse but cannot find a way to programatically select a line (Specifically, for example, either select item 10 or...
6
22130
by: George | last post by:
Hi all, How can I get the value stored from the selected item and subitems of a listview? Thanks in advance, George
7
2026
by: Mike Johnson | last post by:
How do I remove a item that's been selected from a listview? I'm using Visual Basic 2005 express edition. Thanks
3
11622
by: sstein | last post by:
Hi, I am having a bit of trouble with some C# code. I can get it working in VB.NET, but can't seem to work out how to get the same code working in C#. I have a listview which stores information about employees. Basically Day, Hours Worked, Hours Off, Absence Reason, Subs, Pay for day.
4
13852
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 textbox_textchanged to select listview item Listview1.Items(z).Selected = True Listview1.Items(z).EnsureVisible () Listview1.Items(z).FullRowSelect = True Listview1.Items(z).ForeColor = Blue
0
5962
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 show as yellow until I've clicked the same item two times. What am I doing wrong on the selected item that keeps it from changing to yellow until the item is clicked two times? Also, I have to set the listviews selectedIndex in the...
0
8095
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8556
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6068
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5526
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2541
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1690
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.