473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Reading a ListView item

Hello,

I have a ListView in which each item is an array of 5 strings. I add these
string arrays to the ListView by doing the following, where "result" is the
array of 5 strings to add:

listView.Items.Add(new ListViewItem(result));

Now I would like to read one of the items back into an array of 5 strings,
for instance, the array stored as ListView item 0. It seems that the
following would be the symmetrical way of doing it, but obviously it's not:

string [] s = (string [])listView.Items[0];

Of course I can always extract the 5 subitems one at a time into each
element of my string array, but that seems pretty brutal.

Thanks,
Ray

Jul 4 '08 #1
1 2801
Ray Mitchell wrote:
Hello,

I have a ListView in which each item is an array of 5 strings. I add these
string arrays to the ListView by doing the following, where "result" is the
array of 5 strings to add:

listView.Items.Add(new ListViewItem(result));
That doesn't put the array in the ListViewItem. The constructor loops
through the array and creates a subitem for each string in the array.
Now I would like to read one of the items back into an array of 5 strings,
for instance, the array stored as ListView item 0. It seems that the
following would be the symmetrical way of doing it, but obviously it's not:

string [] s = (string [])listView.Items[0];

Of course I can always extract the 5 subitems one at a time into each
element of my string array, but that seems pretty brutal.
Well, that's what you have to do. If you haven't kept the original
array, it doesn't exist any more. Only the separate string in the array
exists, one in each of the subitems.

--
Göran Andersson
_____
http://www.guffa.com
Jul 4 '08 #2

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

Similar topics

6
by: VM | last post by:
How can I fill up a listview with text file contents? My listview has two columns and the first column fills up with a while loop: while (myString != null) { myString = sr.Readline();...
1
by: J_Max | last post by:
Hello, This might be a really easy question, but... I am developing a simple Smart Device application that uses a listview. I have a function that adds a item to the listview - code is below. I...
1
by: Ray Mitchell | last post by:
Hello, In the following code assume that the ListView object "myListView" has been properly created. What I am attempting to do is add a string as a list view item, then read the various string...
2
by: Anushya devi | last post by:
Hi All I used listview and tried to update it by using Addrange. When the number of items is less, it works fine.. But I need to update nearly 200,000 items and it hangs. Also i need to add...
3
by: MikeY | last post by:
Hopefully someone can help me on this. I am using C#, making Windows forms. I have created a listView with checkbox's. I have enabled the checkboxes under the properties, and all the data,...
9
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default windows colour. Can someone please tell me how to...
3
by: Matt Michael | last post by:
I have a listview control and a collection object right now that I'm trying to pass information to and from. Whenever I click on the checkbox, I want it to remove certain listview items and add...
4
by: Pucca | last post by:
How can I tell a mouse right clicks over a listview item that's in a container panel. I only want to display a popup menu if the user right click the mouse over an item on the Listview. I don't...
6
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
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...

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.