c# - 如何暂停 DataTable 通知或数据绑定(bind)以防止 UI 更新

标签 c# winforms data-binding datagrid ultrawingrid

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

我想在用户单击按钮之前更新数据表而不显示数据网格上的任何更改。

我尝试了以下方法来暂停网格更新,但均无效。可能我真的不明白数据绑定(bind)是如何工作的。

  1. ultraGrid.BeginUpdate() - 这是 ultraGrid 特定的方法,用于停止绘制网格。适用于 Aero 主题,但如果您在窗口上使用“经典”主题,则网格不会自行绘制,因为绘画已暂停。

  2. BindingSource.SuspendBinding() - 这只会暂停对基础源的 UI 更改,而不是相反

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

  4. Grid.BindingContext = new BindingContext() - 尝试查看我是否可以删除任何底层绑定(bind)以防止更新网格。这个根本不行不知道怎么用

其他想法:

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

  2. Create snapshot and cover the grid - 这真的是 hack,这是其他人建议的。我正在努力避免进行此类黑客攻击。

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

谢谢

最佳答案

我知道完全抑制任何数据源更改事件的唯一方法是使用 UltraGrid 的 ISupportInitialize 接口(interface)实现:

((ISupportInitialize)Grid).BeginInit();

///
/// your code here
///

((ISupportInitialize)Grid).EndInit();

关于c# - 如何暂停 DataTable 通知或数据绑定(bind)以防止 UI 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7748451/

相关文章:

c# - 事件目录 : The server could not be contacted using DirectorySearcher

c# - 神秘的错误信息 "The port ' COM 1' does not exist"

c# - asp.hyperlink in gridview Format 0 as null

C# SqlCeException : One Line SQL to determine table exists

c# - LINQ to SQL 表达式 "Orderby"帮助

c# - 如何为WinForm、C#制作框架?

c# - 如何将 Paypal 与 WinForm 桌面应用程序集成

javascript - Angular 2属性绑定(bind): how do EventEmitters work?

c# - 使用 BindingSource 绑定(bind)到嵌套属性 - 或者,使实体可绑定(bind)

java - Spring:在 Controller 参数上绑定(bind)集合