c# - clone listview from modal form to listview in child form -


i have form1 parent form , form2 child of form1 , form3 modal form open form2

form2 contains listview1 , form3 contains listview2 .. how clone items listview2 listview1 ?

here's have tried :

on modal form form3 :

public newpurchase clientfrm;  clientfrm = new newpurchase();         clientfrm.updatelistview(this.listview2);         this.close(); 

and on child form form2 :

public void updatelistview(listview listview)     {         foreach (listviewitem item in listview.items)         {             this.listview2.items.add((listviewitem)item.clone());         }     } 

it doesn't give error nothing copied

you can use static method , pass lists to.

 public static void copysourcelist(listview source, listview target)  {      foreach (listviewitem item in source.items)      {          listviewitem temp = (listviewitem)item.clone();         target.items.add(temp);      }  } 

i hope helps you, luck !


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -