如何暂停DataTable通知或数据绑定以防止UI更新 [英] How to suspend DataTable notification or Data Binding to prevent UI update

查看:367
本文介绍了如何暂停DataTable通知或数据绑定以防止UI更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据绑定到DataTable的DataGrid(Infragistic UltraGrid)。



我想更新DataTable,而不会在数据网格上显示任何更改,直到用户单击按钮。



我已经尝试了以下方法挂起网格udpate,而且它们都不工作。可能我真的不了解数据绑定的工作原理。


  1. ultraGrid.BeginUpdate() code> - 这是ultraGrid特定的方法,停止网格绘画。适用于Aero主题,但如果您在窗口中使用经典主题,则绘画暂停后,网格不会绘制。


  2. BindingSource.SuspendBinding() - 这只是暂停UI到基础源,而不是围绕


  3. BindingSource.RaiseListChangedEvent = false - 尝试将其设置为false,但网格仍然自动更新。


  4. code> Grid.BindingContext = new BindingContext() - 尝试查看是否可以删除任何底层绑定以防止网格上的更新。这根本不起作用,不知道如何使用它


其他想法:


  1. ultraGrid.SetDataBinding(null,null)删除网格上的所有信息,这不是我想要的。


  2. 创建快照并覆盖网格 - 这是一个黑客,这是其他。我想避免这样的攻击。<​​/ p>


请注意,在网格更新过程中,用户无法访问因为有一个模态窗口打开。用户通过此模态窗口更新数据表。这个想法是当用户点击确定按钮时,他们会看到网格中的变化。



谢谢

解决方案

我知道完全禁止DataSource更改的任何活动的唯一方法是使用UltraGrid实现的 ISupportInitialize 界面:

 ((ISupportInitialize)Grid).BeginInit(); 

///
///你的代码这里
///

((ISupportInitialize)Grid).EndInit();


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.

  1. 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.

  2. BindingSource.SuspendBinding() - This only suspend UI change to the underlying source, not the otherway around

  3. BindingSource.RaiseListChangedEvent = false - Tried to set it to false, but the grid still update itself.

  4. 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:

  1. ultraGrid.SetDataBinding(null, null) - It basically remove all the information on the grid which is not what I want.

  2. 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

解决方案

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();

这篇关于如何暂停DataTable通知或数据绑定以防止UI更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆