Tuesday, November 26, 2013

Share DataTable event from class to form

Hi,


I have a class where I define and populate a datatable using the fill method of a datadapter.


I also have a form with a progressbar control that I'd like to update as the rows of the datatable get populated.


So, I think that I'd need to put the code to update the progressbar in the dt_RowChanged event (and do row counts), but if the datatable exists in the class and the progressbar exists on my form, how can I leverage the RowChanged event from the class and update the control on form without making it publicly accessible. That seems like bad practice.


I've read that a potential solution would be to have the form subscribe to the dt_RowChanged event in the class. I've also read some material about potentially utilizing a background worker as a solution.


What is the best practice? And if it's subscribing, how might I subscribe to the RowChanged event in my static class so that I can bridge the event with the progressbar?


Thanks,


Mike



No comments:

Post a Comment