c# - Get Item[i] from listview -


i trying item[i] string listview. don't seem understand supposed do, when listview on thread.

public delegate void getcurrentitemcallback (int location); ... private void runasthread() {    while (..>i)    {     //i tried following //doesn't work.     //string item_path = listview.item[i].tostring();         //attempting thread safe. how return string?     string item_path = getcurrentitem(i);    } } private void getcurrentitem(int location) {    if (this.listviewmodels.invokerequired)       {        getcurrentitemcallback d = new getcurrentitemcallback(getcurrentitem);        this.invoke(d, new object[] { location });       }       else       {        this.listviewmodels.items[location].tostring();       } } 

what missing?

you need have delegate type returns string, not void, begin with.

then, need matching method return string well.

public delegate string getcurrentitemcallback (int location);  ...  private string getcurrentitem(int location) {    if (this.listviewmodels.invokerequired)       {        getcurrentitemcallback d = new getcurrentitemcallback(getcurrentitem);        return this.invoke(d, new object[] { location });       }       else       {        return this.listviewmodels.items[location].tostring();       } } 

Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -