c# - Adding Columns and ListView items -
this first foray c# winforms, , i'm trying create listview grid.
my code looks this:
listview1.columns.add("name", 100); listview1.columns.add("col2", 200); listview1.columns.add("col3", 300); string[] arr = new string[3]; arr[0] = "product_1"; arr[1] = "100"; arr[2] = "10"; string[] arr2 = new string[3]; arr[0] = "product_2"; arr[1] = "200"; arr[2] = "20"; listviewitem itm = new listviewitem(arr); listviewitem itm2 = new listviewitem(arr2); listview1.items.add(itm); istview1.items.add(itm2);
but output looks this:
so few questions here:
- why not see column names?
- why not see grid lines?
- why last entry being displayed (product2)?
- why there no information other string "product2" displayed, rather other column entries?
any appreciated!
the default viewstyle of listview
largeicon. in view, no columns or details displayed. if want columns visible, should set view
property of listview details
:
listview1.view = view.details;
on sidenote: when you're adding lots of listviewitems, might better use addrange method instead of adding each item seperatly. improve performance. also, make use of beginupdate() , endupdate() methods on listview. prevent listview redrawn each add of listviewitem.
Comments
Post a Comment