Click here to Skip to main content
16,004,782 members

Comments by leprechauny (Top 19 by date)

leprechauny 7-May-13 16:37pm View    
Deleted
Sorry for reopening this thread after this long. I've haven't really had time to fiddle around with this project for a while.

public List<ListViewItem> SaveListView(ListView LV)
{
System.Collections.Generic.List<ListViewItem> lSavedLV = new List<ListViewItem>();

for (int i = 0; (i <= animalList.Count - 1); i++)
{
lSavedLV.Add(LV.Items[i]);
}

return lSavedLV;
}

Is that a plausible solution for the saving part? Is that the way to go, if I plan to fill the ListView with such serialised data? Is this then a matching loading method:

public ListView LoadListView(List<ListViewItem> L)
{
ListView lv = new ListView();

for (int i = 0; (i <= (L.Count - 1)); i++)
{
ListViewItem lvi = new ListViewItem();
lvi = ((ListViewItem)(L[i]));
lv.Items.Add(lvi);
}

return lv;
}
leprechauny 5-Apr-13 12:07pm View    
Ah, it's a System.Windows.Forms.ListView. I was thinking that the .AddRange would solve it easily but there is something that I'm missing.
leprechauny 4-Apr-13 16:04pm View    
Just a simple one. How would I, in the most appropriate way (is there ever one), populate a ListView with a List<ListViewItem>?

Thanks in advance!
leprechauny 3-Apr-13 17:41pm View    
Alright. So I'll make some changes to the helper methods so that they return a List<ListViewItem> - that also seems more plausible. Wouldn't one be able to populate the ListView quite easily with such a list as well?

Thanks for the quick and great comments by the way.
leprechauny 3-Apr-13 16:41pm View    
Ye, Sergey, that was pretty much what I was going for. And also what those helper methods was for, but obviously that was where I went wrong, it seems. The idea was that the data would be stored in the ArrayList, in order to avoid serializing the whole ListView control.

Anyways, could you specify or give me a hint of a data layer example? So I get an idea of where I'm to be headed.