Hi all,

I am trying to write a code that could show multiply values in a single cell of listview with comma separator... i am using C# with windows application...

I have a attachment that show what i am asking for...

Thanks in advance
vince

Attachments likethis.png 3.97 KB

Did you tryed to join all the values in a string, then use it to fill the list view subitem?

IE:

string thetextToShowInTheCell="";
foeach(string valueToshow in ListOfStringValuesToShowInTheCell){
    if (thetextToShowInTheCell.Length>0) thetextToShowInTheCell+=", ";
    thetextToShowInTheCell += valueToshow; }

Hope this helps

I tried that method .. but it is showing ArgumentOutOfRange expection...

And it also shows erros as "can not insert value in this position. Remove the previous value and insert or clone it"
I dont know why it is asking to clone the values to be shown...????

Any other methods..???

thanks for replying.
vince

Hello Vince,

Here you go.

ListViewItem lvi = new ListViewItem( new string[] {"1", "2", "3", "4"});
yourListView.Items.Add(lvi);

Let me know if you succeed.

Bye.

Sorry, miss read your question. Here is the new better code.

string[] list = { "1", "2", "3", "4" };  

string all = String.Join(",", list);

ListViewItem lezen = new ListViewItem( new string[] { all, "2", "3", "4"});

Edited 5 Years Ago by Three: Typo.

Hello,

After this peace of code there is only one line:

listView.Items.Add(lezen);

Hope this helps.

Thanks all for ur replies... i have used lola's idea and Three idea to get the desired output.. thanks
vince

This question has already been answered. Start a new discussion instead.