如何暂停 DataTable 通知或数据绑定以防止 UI 更新

发布于 2024-12-09 17:17:42 字数 870 浏览 0 评论 0原文

我有一个数据网格(Infragistic UltraGrid),它的数据绑定到数据表。

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

我尝试了以下方法来暂停网格更新,但都不起作用。可能我不太明白数据绑定是如何工作的。

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

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

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

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

其他想法:

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

  2. 创建快照并覆盖网格 - 这确实是一个 hack,这是其他人建议的。我试图避免这样做。

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

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

如梦初醒的夏天 2024-12-16 17:17:42

我知道完全抑制数据源更改上的任何活动的唯一方法是使用 UltraGrid 的 ISupportInitialize 接口实现:

((ISupportInitialize)Grid).BeginInit();

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

((ISupportInitialize)Grid).EndInit();

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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文