Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1182
  • Last Modified:

Populate unbound DataGridView column from a BackGroundWorker

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?

Thanks,
Chris
0
chlade
Asked:
chlade
  • 2
  • 2
2 Solutions
 
DabasCommented:
Instead of finding through the DataGridView, have you tried to find the row in the object the DataGridView is bounded to?

Dabas
0
 
chladeAuthor Commented:
The image column wasn't bound.  I tried creating a new column in the datatable and binding with it.  I then populate this in the ProgressChanged event.  The problem is that this hangs the app for some reason for the entire time that the BackGroundWorker is running.  This is the whole reason I'm using it in the first place.  
0
 
DabasCommented:
I know the image column is unbound, but you asked how to find the row to update, and I was suggesting that you find it through the object behind the DataGridView instead of through the non existing Find option of the DGV you mentioned.

As to the app hanging, without seeing any code at all, it is virtually impossible to know what is wrong

Dabas
0
 
chladeAuthor Commented:
I ended up doing the following.  Prior to calling the background worker, I filled a List with the data needed for the background worker.  I filled the list in order from the first row to the last row in the datagridview.  I then passed this List to the backgroundworker.  Then, I had it update the progress after each record was processed.  In doing so, I could just use the row index to update the proper row in the datagridview.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now