|
Greetings,
Is there a way to disable update notifications on a DataTable (or DataSet) so that changes I make to the table (data, not structure of the table) are not reflected in bound components (such as a DataGridView)?
I know, for instance in my DataGridView forms, I can change the RaisedListChangedEvent property in my BindingSource, however this is not possible, because I don't necessarily know what UI components are bound to my DataSet, I simply want to tell the DataSet "do not raise any update events when I modify you".
The problem is, I sometimes make thousands of updates per second to my DataTables and the UI has trouble keeping up with every one. What I'd like to do is periodically (with the use of a Timer) re-enable update notifications so the UI elements can refresh, but for all of the intermittent updates, i do not want them to update.
Thanks.
| | slikrik Friday, December 05, 2008 1:04 PM | You could always bind your datatable to a bindingsource and the bindingsource to the datagridview. Call tge bindingsource's suspendbinding method to cancel the updates. Use resumebinding to restart the updates,
http://msdn.microsoft.com/en-us/library/system.windows.forms.bindingsource.suspendbinding.aspx
| | Ken Tucker Friday, December 05, 2008 5:19 PM | Ken,
Thanks. Unfortunately, though, some of my UI components that are bound to this DataTable aren't bound in the traditional way -- for instance, I have a DataGridView that changes the background colors of certain cells if a particular row exists in a DataTable.
So, my DataGridView isn't "bound" to the DataTable per se, rather I subscribe to
MyStronglyTypedDataTable.StronglyTypedDataRowChanged
event. So that whenever a row is modified, added, or deleted, I make changes to my DataGridView manually. Therefore, I'm not using a BindingSource. I'd like to be able to momentarily disable the MyStronglyTypedDataTable.StronglyTypedDataRowChanged event being raised, so that I can make my numerous updates to the table and not have EVERY one of them reflected. So I think I'm going to have to do this disabling at the DataTable level. Unless you can think of another way to achieve this?
Thanks again, Rick
| | slikrik Friday, December 05, 2008 6:54 PM |
Hi slikrik,
What does “MyStronglyTypedDataTable.StronglyTypedDataRowChanged�mean in your post? I can’t fully understanding your requirement. If you want to temporarily disable an event, you can use [event name] -= [delegate].
If I misunderstood something, please feel free to tell me.
Sincerely,
Kira Qian | | Kira Qian Monday, December 08, 2008 9:20 AM | Kira,
Sorry for the confusion -- what that meant was, whenever you have the wizard create the strongly-typed DataSet for you, each of the tables is given a typed event to which you can subscribe, for the generic DataRowChanged event. In my example, I had a strongly-typed data table called:
MyStronglyTypedDataTable
And the event, that the wizard created, for when row updates occur, was
MyStronglyTypedDataRowChanged.
The problem is, I have several UI components that subscribe to this event -- so that when changes occur programmatically to the underlying DataTable, my UI components can update. So, in this case, they are "bound" to the DataTable but not in the traditional way.
What I need to be able to do is to disable the firing of this event -- I can't rely on each UI component unsubscribing and then resubscribing to this event; rather, I need a way to tell my DataTable "don't fire any events when I make changes to you."
Thanks, Rick
| | slikrik Monday, December 08, 2008 3:33 PM | Kira,
It appears you have responded to my last post (on the "MyThreads" view, it says you were the last person to post in this thread, last night at 9:51pm), but I don't see any post after my last one on 12/8! I think this is a forum that was recently ported to the new system, so I'm wondering if that has anything to do with it?
If possible, could you re-post your message? I still haven't figured this issue out. Thanks!
Rick | | slikrik Thursday, December 11, 2008 1:06 PM |
|