c# - Move Listview with datatable into another listview -
i want move selected row listview beside it. source listview has fullrowselect = true , multiselect = false. source listview populated via data table database.
here have far. moves selected item. want move whole selected row.
private static void moveselecteditems(listview source, listview target) { (int = 0; < source.items.count; i++) { if (source.items[i].selected) { target.items.add(source.items[i]); } } }
this happens when run code.
firstly, since have set multiselect
false, dont need loop iterate on items.
secondly, moving part simple. take selected item , add in target items. since moving, , not copying, remove item source listview.
private static void moveselecteditems(listview source, listview target) { if(source.selecteditems.count > 0) { listviewitem selecteditem= source.selecteditems[0]; foreach (var subitem in source.selecteditems[0].subitems) { selecteditem.subitems.add (subitem); } source.items.remove(selecteditem); target.items.add(selecteditem); } }
Comments
Post a Comment