I have two forms using a ListView component. In the first form it works perfectly (all items are printed in the ListView), while in the second (which has the same structure) no, the ListView stays blank.
What I’m doing wrong?
lista is a list.
The number of elements = longitud, which is defined in the main function.
There is the code:
public void llenarTabla()
{
int idx;
string tmp;
string elemento;
for (idx = 0; idx < longitud; idx++)
{
tmp = Convert.ToString(idx + 1);
ListViewItem lvi = new ListViewItem(tmp);
elemento = Convert.ToString(lista[idx]);
lvi.SubItems.Add(elemento);
listView1.Items.Add(lvi);
listView1.View = View.Details;
listView1.Refresh();
}
}
-
I also tried to see if the list has any elements (as it is supposed to be):
for (int idx = 0; idx < longitud; idx++) // test Console.WriteLine(lista[idx]);
and in the “output window” it prints some elements.
- I also tried to put
.View = ...and.Refresh()outside the cycle. But same result.
Thank you for any help
Maybe you have forget to set property View to View.Details.