I have ListView listViewListaChamada
and I'm trying to add columns and values to the columns corresponding to my ListView listViewListaChamada
, but I did not succeed. I created the function below to popular my ListView:
private void PopulaListView(MListaPresenca lista_chamada, ListView listview, MAluno aluno)
{
listview.Items[0].SubItems.Add(aluno.Nome);
listview.Items[1].SubItems.Add(lista_chamada.Presente);
}
Where the first column receives the nome
of the student and the second column receives the value of the Presente
attribute whose value can be SIM
or NÃO
, so my ListView
will have two columns, however, at the moment of entering the values I get the following error:
"InvalidArgument = Value '0' is not a valid value for 'index'. \ r \ nName of the parameter: index "
I would like to know how to add columns and values in the columns of my ListView
at run time?