I'm learning on how to access MySQL database using C# by following this guide
In those codes, it uses List<string>[4]
to store the Selected data because it has 4 columns
After some experiment, I found out that those codes store the data in a format like this:
//List[0] = Name1, Name2, Name3, ...
//List[1] = Age1, Age2, Age3, ...
//...
I want to access the data row by row and display it in ListView
,
but if we use foreach
, it will list the data column by column
foreach (List<string> entry in dataEntries){
ListViewItem lvi = new ListViewItem(entry[0]); //refer to Name1 during first loop
lvi.SubItems.Add(entry[1]); //Name2
lvi.SubItems.Add(entry[2]); //Name3
lvi.SubItems.Add(entry[3]); //and so on
listView1.Items.Add(lvi);
}
Is there a way to display it row by row? Or is there any simpler workaround?