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.

listview

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.

output

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

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -