问题
I got a DataGrid (Infragistic UltraGrid) that is databinded to a DataTable.
I would like to update the DataTable without showing any changes on the data grid until user click a button.
I have tried the following methods to suspend the grid udpate, and none of them works. Probably I don't really understand how data binding works.
ultraGrid.BeginUpdate()
- this is ultraGrid specific method that stop grid from painting. Works well with Aero theme, but if you use "classic" theme on window, the grid doesn't draw itself since painting is suspended.BindingSource.SuspendBinding()
- This only suspend UI change to the underlying source, not the otherway aroundBindingSource.RaiseListChangedEvent = false
- Tried to set it to false, but the grid still update itself.Grid.BindingContext = new BindingContext()
- trying to see if I can remove any underlying binding to prevent update on the grid. This doesn't work at all and don't know how to use it
Other ideas:
ultraGrid.SetDataBinding(null, null)
- It basically remove all the information on the grid which is not what I want.Create snapshot and cover the grid - This is really a hack, which was suggested by other. I am trying to avoid doing such hack.
Please note that during the grid update, user can't access the grid because there is a modal window open. The user update the data table though this modal window. The idea is that when user click the OK button, they will see the changes in the grid.
Thanks
回答1:
The only way I know to totally suppress any activity on DataSource change is to use UltraGrid's implemenation of ISupportInitialize interface:
((ISupportInitialize)Grid).BeginInit();
///
/// your code here
///
((ISupportInitialize)Grid).EndInit();
来源:https://stackoverflow.com/questions/7748451/how-to-suspend-datatable-notification-or-data-binding-to-prevent-ui-update