PC Review


Reply
Thread Tools Rate Thread

Adding an object to listview-item?

 
 
Boris Nienke
Guest
Posts: n/a
 
      26th Nov 2003
hi,

i would like to store an object along with an listview-item. Something
like:

ListViewItem item = new ListViewItem();
item.Text = "Text"
item.SubItems.Add("Text2")

item.Object = MyObject;

listview1.Items.Add(item);

Is this possible? And how to get the selected item/object when the user
clicks the item?

thank you

Boris
 
Reply With Quote
 
 
 
 
Alex Yakhnin [MVP]
Guest
Posts: n/a
 
      26th Nov 2003
Create your own ListViewItem by deriving from it and add
Object or Tag property.

HTH... Alex

--
Alex Yakhnin, .NET CF MVP

>-----Original Message-----
>hi,
>
>i would like to store an object along with an listview-

item. Something
>like:
>
> ListViewItem item = new ListViewItem();
> item.Text = "Text"
> item.SubItems.Add("Text2")
>
> item.Object = MyObject;
>
> listview1.Items.Add(item);
>
>Is this possible? And how to get the selected item/object

when the user
>clicks the item?
>
>thank you
>
>Boris
>.
>

 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      26th Nov 2003
See http://www.alexfeinman.com/samples.asp ListViewDemo.zip

"Boris Nienke" <(E-Mail Removed)> wrote in message
news:1jqmjpyzo3p4.mkp3w939yitt$.(E-Mail Removed)...
> hi,
>
> i would like to store an object along with an listview-item. Something
> like:
>
> ListViewItem item = new ListViewItem();
> item.Text = "Text"
> item.SubItems.Add("Text2")
>
> item.Object = MyObject;
>
> listview1.Items.Add(item);
>
> Is this possible? And how to get the selected item/object when the user
> clicks the item?
>
> thank you
>
> Boris



 
Reply With Quote
 
Boris Nienke
Guest
Posts: n/a
 
      27th Nov 2003
On Wed, 26 Nov 2003 15:13:21 -0800, Alex Feinman [MVP] wrote:

> See http://www.alexfeinman.com/samples.asp ListViewDemo.zip


Thanks a lot! That worked!

Boris
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to select the first item (the one at the top) of an ordered ListView object polocar Microsoft C# .NET 1 13th Apr 2007 01:04 PM
help coloring individual listview item instead of all listview item in visual c++ tonyck Webmaster / Programming 0 7th Jul 2006 11:06 AM
Adding a listview item =?Utf-8?B?ZG90bmV0bmV3Ymll?= Microsoft VB .NET 2 14th Jul 2005 11:28 AM
Adding A Tooltip To A ListView Item Dino Buljubasic Microsoft VB .NET 1 9th Jun 2004 11:08 PM
Listview Item.Selected not populating Listview.SelectedItems collection Chris Adams Microsoft Dot NET Framework Forms 0 23rd Apr 2004 01:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:07 AM.