Reputation: 3515
I'm using listbox to display list of data, I tried with this
foreach (MyData a in data)
{
var row = new ListViewItem();
row.Text = a.Name;
row.SubItems.Add(a.Code);
row.SubItems.Add(a.Name2);
listView1.Items.Add(row);
}
This way I'm getting data displayed inside columns and I need to display inside row, also subitems Code and Name2 are not displayed.
What I'm doing wrong here
Upvotes: 0
Views: 198
Reputation: 236218
In order to see subitems you need to use Details
mode of ListView
. Also make sure you have added three columns to listview (you can do it in designer):
listView.Columns.Add("Name");
listView.Columns.Add("Code");
listView.Columns.Add("Name2");
listView.View = View.Details;
// ... your code
Upvotes: 1