Populate unbound DataGridView column from a BackGroundWorker
Posted on 2009-02-24
I have an application that shows a large DataGridView full of items. When the user clicks Search, a stored procedure fills up a local DataTable that is used as the DataSource for the DataGridView. Then, a BackGroundWorker process is kicked off. This process goes through each row and sees if there is an image for the item on the file system. If so, the image is loaded and displayed in an unbound column on the DataGridView.
Here is my dilemma. How can I accomplish this? Originally, we didn't use a BackGroundWorker but it tied up the system too long trying to load the items. There may possibly be several thousand rows.
So we moved the image logic to a BackGroundWorker. However, we cannot update the UI from here. I can update it in the ProgressChanged event. However, how do I know which row to update in the DataGridView? I don't see a Find option for the DataGridView. I can search the DataTable, but the image is going to be put in an unbound column so that doesn't seem to help.
I also looked at making the image bound. I created a new field in the DataTable and tried to manually populate it in the BackGroundWorker. However, I couldn't figure out what type of DataTable column to create to store the image.
Anyway, that should give an idea of what I'm looking at. Any ideas on the best way of handling this?