Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add selected listview key to text box 1

Status
Not open for further replies.

OMoore

Technical User
Oct 23, 2003
154
EU
I have a listview (ListView1) whereby I want the selected Key value to appear in a textbox (Text1). I also need the subitem for the listview to appear in another text box (text2). I've tried several codes but being a noobie i'm not having much luck at the moment. Anyone got any similar codes or ideas?

Thanks
Owen
 
Am I missing something?

Text1.Text = ListView1.SelectedItem.Key
Text2.Text = ListView1.SelectedItem.SubItems(1)


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Thanks John (again). I thought it was a lot more complicated and was getting carried way..
I've removed the "Key" text to make it work correctly. The code I've used is..

Text1.Text = ListView1.SelectedItem
Text2.Text = ListView1.SelectedItem.SubItems(1)

Thanks again.
Owen
 
Note that ListView1.SelectedItem will give you the value of the Item not the value of the Key (which you originally requested)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
(and thanks for the star!) [smile]

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top