Reading a ListView item

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?UmF5IE1pdGNoZWxs?=

    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(re sult));

    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

  • =?UTF-8?B?R8O2cmFuIEFuZGVyc3Nvbg==?=

    #2
    Re: Reading a ListView item

    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(re sult));
    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
    _____
    Göran Anderssons privata hemsida.

    Comment

    Working...