Hi everyone.
In a little program i am writing i have a listview, i fill it with data from
an ArrayList which contains a lot of objects. The data for the columns are
differente fields in the objects in the ArrayList.
I have also added column sorting, when a user clicks a column.
All that works fine.
But when a user double clicks a line in the listview (detail mode), an event
is raised, and i get the 'selectedItems' from the listview. From this list i
can find the data in the line that has been clicked.
But my problem is how du i figure out which object from the ArrayList this
line reflects ?
I can have 100% equal objects in the ArrayList.
I could of course add a unique ID for each object, but have not been able to
figure out how to add that to the ListView without showing it to the user.
Can anybody please help me ?
Best regards
Søren Reinke 5 1696
I noticed if a add data to a column that does not have a name, it is not
displayed, and then i can use it as an unique ID.
Is that an acceptable way to do it ?
Best regards
Søren Reinke
"Søren Reinke" <so***@reinke.fjernmig.dk> wrote in message
news:d3**********@newsbin.cybercity.dk... Hi everyone.
In a little program i am writing i have a listview, i fill it with data from an ArrayList which contains a lot of objects. The data for the columns are differente fields in the objects in the ArrayList.
I have also added column sorting, when a user clicks a column. All that works fine.
But when a user double clicks a line in the listview (detail mode), an event is raised, and i get the 'selectedItems' from the listview. From this list i can find the data in the line that has been clicked.
But my problem is how du i figure out which object from the ArrayList this line reflects ?
I can have 100% equal objects in the ArrayList.
I could of course add a unique ID for each object, but have not been able to figure out how to add that to the ListView without showing it to the user.
Can anybody please help me ?
Best regards Søren Reinke
You can use the ListViewItem.Tag property to store information about an
object: http://msdn.microsoft.com/library/de...sstagtopic.asp
MyObject object = new MyObject("abcde");
ListViewItem item = new ListViewItem();
item.Text = "Some caption";
item.Tag = object;
--------------------------------
MyObject object = null;
ListViewItem item = mylistview.Items[0];
myobject = (MyObject)item.Tag;
Alex
"Søren Reinke" <so***@reinke.fjernmig.dk> wrote in message
news:d3**********@newsbin.cybercity.dk... Hi everyone.
In a little program i am writing i have a listview, i fill it with data from an ArrayList which contains a lot of objects. The data for the columns are differente fields in the objects in the ArrayList.
I have also added column sorting, when a user clicks a column. All that works fine.
But when a user double clicks a line in the listview (detail mode), an event is raised, and i get the 'selectedItems' from the listview. From this list i can find the data in the line that has been clicked.
But my problem is how du i figure out which object from the ArrayList this line reflects ?
I can have 100% equal objects in the ArrayList.
I could of course add a unique ID for each object, but have not been able to figure out how to add that to the ListView without showing it to the user.
Can anybody please help me ?
Best regards Søren Reinke
Hi Reinke,
add a Hidden Column in the listView that will contain the index of the
object, you will assing the index for every row you add so you will be able
to now the possition in the arrayList.
Hope that Helps
"Søren Reinke" <so***@reinke.fjernmig.dk> wrote in message
news:d3**********@newsbin.cybercity.dk... Hi everyone.
In a little program i am writing i have a listview, i fill it with data from an ArrayList which contains a lot of objects. The data for the columns are differente fields in the objects in the ArrayList.
I have also added column sorting, when a user clicks a column. All that works fine.
But when a user double clicks a line in the listview (detail mode), an event is raised, and i get the 'selectedItems' from the listview. From this list i can find the data in the line that has been clicked.
But my problem is how du i figure out which object from the ArrayList this line reflects ?
I can have 100% equal objects in the ArrayList.
I could of course add a unique ID for each object, but have not been able to figure out how to add that to the ListView without showing it to the user.
Can anybody please help me ?
Best regards Søren Reinke
Using the ListViewItem.Tag property is the correct way to do it. You
can store either an index value or a reference to the object itself in
the Tag, depending upon what you want to do.
I just wish that ComboBox entries had a Tag property, too. :(
"Alex Passos" <bz@netmerlin.nospam.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl... You can use the ListViewItem.Tag property to store information about an object:
http://msdn.microsoft.com/library/de...sstagtopic.asp
MyObject object = new MyObject("abcde"); ListViewItem item = new ListViewItem(); item.Text = "Some caption"; item.Tag = object;
Thanks for all the answers, the .Tag was just what i was looking for.
Best regards
Søren Reinke This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Eva |
last post by:
Hi,
I wanted to know how i can enter values into a specific
column of a listview. I have tried the following code but
this seems to enter all my values into the first column!!!
Can anyone...
|
by: MrB |
last post by:
I am quite new to vb.net. I have been using VBA for years, but an having
problems with populating a listview. I have tried many things, including
snippets of code from some news groups with no...
|
by: Richard |
last post by:
Hi. I use a ListView to display data in tabular form.
Each ListView row corresponds to a data record.
The ListView Item of the record is the record key or code.
Each SubItem in that row...
|
by: pointBoarder |
last post by:
I'm following the article from
http://support.microsoft.com/default.aspx?scid=kb;en-us;155178
The above article explains how to fill a listview. For some reason I
keep recieving "User-defined...
|
by: MikeY |
last post by:
Hi all,
I am coding window forms in C#.
My problem is this: I have created a "Check ListView" or a 'ListView' with
checkbox's. I have populated the it with my files from my folders, mps, txt,...
|
by: TarheelsFan |
last post by:
I am having problems with drag and drop into a listview. I am able to
drag and drop items from within the listview, as well as drag items
from the listview and drop into a picturebox. However, I...
|
by: Michael.Suarez |
last post by:
Is it me, or does it seem like they put no effort into creating the
listview control in .Net.
listview.
A few gripes I have with .Net listview that aren't present in vb6:
-Inability to set...
|
by: garyusenet |
last post by:
I have had no replies to my previous post so perhaps I didn't write it
good enough.
Please excuse new thread but i wanted to break from the last thread
hopefully this thread will be better.
...
|
by: Griff |
last post by:
I have a Windows appliction that I want to turn into a WPF application (as a
proof of concept).
However, I have encountered a problem with the ListView object and I can't
find any suitable help...
|
by: Lord Zoltar |
last post by:
Hi,
I've got a list view that displays a series of images. I'd like to be
able to draw a divider across the list view to divide the images into
groups. Ideally, I'd have a group name, with a line...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: 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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |