datagridview在填充期间触发事件 [英] datagridview firing off events during fill

查看:58
本文介绍了datagridview在填充期间触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Winforms app

我有一个带有许多自定义处理程序的datagridview。

I have a datagridview with many custom handlers.

我注意到了当数据最初加载到网格中时,导航事件会被触发数百万次。

I am noticing that the navigation events are firing off millions of times while the data is being loaded into the grid initially.

我已经在设置名为isFetchingData的bool的代码中填充了数据,我检查了它执行导航事件。

I have wrapped the filling of data in code that sets a bool named isFetchingData, and I check it on execute of the navigation events.

        private void GetData()
        {
            isFetchingData = true;
            orderAddDataset1.EnforceConstraints = false;
            this.purchase_OrderTableAdapter.Fill(this.orderAddDataset1.Purchase_Order, Customer, PO);
            this.purchase_Order_DetailTableAdapter.Fill(this.orderAddDataset1.Purchase_Order_Detail, Customer, PO);
            this.v_order_totalsTableAdapter.Fill(this.orderAddDataset1.v_order_totals, Customer, PO);
            orderAddDataset1.EnforceConstraints = true;
            this.Refresh();
            isFetchingData = false;
        }



$



isFetchingdata设置为false后发生以下事件...

The following events are happening AFTER the isFetchingdata has been set to false...

CurrentCellChanged -   CellEnter -   RowLeave -   CellValidated

CurrentCellChanged - CellEnter - RowLeave - CellValidated

CurrentCellChanged - CellEnter - RowLeave - CellValidated

CurrentCellChanged - CellEnter - RowLeave - CellValidated

4次。

这些事件只应在USER与之交互时触发datagridview。

These events should only fire when the USER interacts with the datagridview.

由于填充操作会触发所有导航事件,如何封装填充操作,以便在用户控制表单之前我可以忽略所有这些操作?   ;

Since the fill operation fires off all the navigation events, How do I encapsulate the fill operation so I can ignore all these until the user has control of the form?  

我可以看到一些程序员想要在填充过程中捕获这些事件,但必须有一些方法知道何时填充网格,然后打开这些处理事件。

I can see how some programmers would want to capture these events during a fill, but there must be SOME WAY to know when the grid is filled, and then turn on the processing of these events.

请注意上面的代码应该这样做: 在例程结束时填充数据源。 我想datagridview只是以某种方式异步同步到数据。

Note the code above SHOULD have done this:  the datasources are filled at the end of the routine.  I guess the datagridview just syncs up to the data asynchronously somehow.

我宁愿生活在虚假的希望而不是虚假的绝望。

I'd rather live with false hope than with false despair.

推荐答案

感谢您在这里发帖。

对于与WinForm应用程序开发更相关的案例,我将把它移到WinForm论坛以获得更好的支持。

For your case which is more related to WinForm application development, I will move it to WinForm forum for better support.

您的理解与合作将不胜感激。

Your understanding and cooperation will be grateful.

最好的问候,

Baron Bi


这篇关于datagridview在填充期间触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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