I need to access a listview's items in a DoWork event handler. For this the delegate and the method to invoke the listview what I wrote is:
delegate ListView itemDelegate(ListView bufferedListView1);
private ListView getItems(ListView bufferedListView1)
{
if (bufferedListView1.InvokeRequired)
{
// BeginInvoke(new itemDelegate(getItems));
bufferedListView1.Invoke(new itemDelegate(getItems));
}
else
{
return bufferedListView1;
}
}
This is the first time I am working with invoking a control. So please let me know where I am wrong. One error that I get is gsm_modem.Form1.getItems(System.Windows.Forms.ListView): not all code paths return a value
. I even guess that what I wrote might be wrong. Correction please..
Thanks to @Ravi patel for the idea. This is what I did to solve the problem:
Then used listItems in my other thread easily.