How to update correct form control with data got from server?

B

Bruce

Hi
I am implementing a simple app in C# where I show a list of files in a
form. (set of ListViewItems in ListView.Items)
I create these ListViewItems using an arraylist of my custom objects
FileObj (each ListViewItem's Tag property refers to the corresponding
FileObj object)

Now, when the user clicks on a file and chooses some operation, I use
delegates to process the request in a worker thread. Once it is done,
it calls back into the UI thread. Then, I need to update a column in
the view for the file on which the operation was done. (i want to
change column value to "operation done")

Now, my problem is, how do I find which file in the list view I need
to update? How do I map the response to the correct ListViewItem?
I do not want to redraw the entire view since I could have 100s of
files. But I also do not want to add some property like view index in
FileObj class since I want to separate the view and model.

Is there a clean way to do this?

Thanks
Bruce
 
G

Guest

Bruce said:
Hi
I am implementing a simple app in C# where I show a list of files in a
form. (set of ListViewItems in ListView.Items)
I create these ListViewItems using an arraylist of my custom objects
FileObj (each ListViewItem's Tag property refers to the corresponding
FileObj object)

Now, when the user clicks on a file and chooses some operation, I use
delegates to process the request in a worker thread. Once it is done,
it calls back into the UI thread. Then, I need to update a column in
the view for the file on which the operation was done. (i want to
change column value to "operation done")

Now, my problem is, how do I find which file in the list view I need
to update? How do I map the response to the correct ListViewItem?
I do not want to redraw the entire view since I could have 100s of
files. But I also do not want to add some property like view index in
FileObj class since I want to separate the view and model.

Is there a clean way to do this?

Thanks
Bruce
Hello,

There is a simple way doing this without interfere the UI thread, think on
data binding to file list set by index (hash code - for each item in the data
list), all the process tou depict will change the data list (bounded to the
ListView ), using the hash code you can reffer to the specific file.

Thanks.

Hope it will help you.

Yaron
http://dotnetbible.blogspot.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top