This is my first foray into C# WinForms, and I'm trying to create a ListView grid.
My code looks like this:
string arr = new string;
arr = "product_1";
arr = "100";
arr = "10";
string arr2 = new string;
arr = "product_2";
arr = "200";
arr = "20";
ListViewItem itm = new ListViewItem(arr);
ListViewItem itm2 = new ListViewItem(arr2);
The default viewstyle of a
ListView is LargeIcon. In that view, no columns or details are displayed.
If you want your columns to be visible, you should set the
View property of the ListView to
listView1.View = View.Details;
On a sidenote: when you're adding lots of ListViewItems, it might be better to use the AddRange method instead of adding each item seperatly. That will significantly improve performance. Also, make use of the BeginUpdate() and EndUpdate() methods on the ListView. This will prevent the ListView to be redrawn with each add of a ListViewItem.