c# - c sharp -winform application with a listview -
i have listview in c sharp windows forms application in following. following code of lines there in form_load() method .
but issue not start inserting row first column. instead , starts second column. because of value passed last column lost.
listview1.columns.add("columnone", 150); listview1.columns.add("columntwo", 150); listview1.columns.add("columnthree", 150); listview1.columns.add("columnfour", 150); listview1.columns.add("columnfive", 150); listview1.columns.add("column6", 150); foreach (myclass et in _mydata) { listviewitem lt = new listviewitem(); lt.subitems.add(et.dataone.tostring()); lt.subitems.add(et.datatwo.tostring()); lt.subitems.add(et.datathree.tostring()); lt.subitems.add(et.datafour.tolongdatestring()); lt.subitems.add(et.datafive); lt.subitems.add(et.datasix); }
i tried possible. don't see have made mistake. can pls give me solution ?
the listview
bit clunky when comes different columns. shown in first column in detail
view text of listviewitem
, not first subitem
. want start assigning datatwo
, on subgroups
, dataone
listviewitem.text
:
listview1.columns.add("columnone", 150); listview1.columns.add("columntwo", 150); listview1.columns.add("columnthree", 150); listview1.columns.add("columnfour", 150); listview1.columns.add("columnfive", 150); listview1.columns.add("column6", 150); foreach (myclass et in _mydata) { listviewitem lt = new listviewitem(et.dataone.tostring()); lt.subitems.add(et.datatwo.tostring()); lt.subitems.add(et.datathree.tostring()); lt.subitems.add(et.datafour.tolongdatestring()); lt.subitems.add(et.datafive); lt.subitems.add(et.datasix); // added code listview1.items.add(lt); }
Comments
Post a Comment