c# - How do I add another subitem in a listview item after its done downloading? -


i have application listview control , button. when press button want add time , name of file listview , add control, once done downloading file want add subitem same listview reason not adding , cant figure out why, calling wrong?

using system; using system.componentmodel; using system.net; using system.windows.forms;  namespace listviews {     public partial class form1 : form     {         public form1()         {             initializecomponent();         }         listviewitem lvi = new listviewitem();         webclient webclient;           public void downloadfile(string urladdress, string location)         {             using (webclient = new webclient())             {                 webclient.downloadfilecompleted += new asynccompletedeventhandler(completed);                  try                 {                     // start downloading file                     webclient.downloadfileasync(new system.uri(urladdress), location);                 }                 catch (exception ex)                 {                     messagebox.show(ex.message);                 }             }         }          // event trigger when webclient completed         private void completed(object sender, asynccompletedeventargs e)         {             if (e.cancelled == true)             {                 messagebox.show("download has been canceled.");             }             else             {                 listviewitem lvitems = new listviewitem();                 lvitems.subitems.add("done");                 listview1.items.add(lvitems);             }         }           private void btnadd_click(object sender, eventargs e)         {             listviewitem lvitems = new listviewitem();             string clock = datetime.now.tostring("hh:mm");             lvitems.text = clock;             listview1.items.add(lvitems);              string requesturl = "url";             string filename = "\\name";             string savepath = environment.getfolderpath(environment.specialfolder.desktop);              string combinedpaths = savepath + filename;             downloadfile(requesturl, combinedpaths);         }     } } 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -