多个DataBindingComplete事件处理程序 [英] Multiple DataBindingComplete event handlers

查看:102
本文介绍了多个DataBindingComplete事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在窗体上有两个DataGridView 控件(实际上我有很多控件,但出于问题的目的,让我们保持简单).

我通过SQL查询和数据绑定来填充这些DataGridView.现在,完成绑定后,每个DataGridView都将触发DataBindingComplete事件.我有一个事件处理程序来处理所有这些事件.我需要一种方法来了解所有DataGridView何时完成了它们的数据绑定,而不仅仅是它们中的任何一个.

I have two DataGridView controls on my form (actually I have plenty but let''s keep it simple for the purpose of the question).

I''m populating these DataGridViews through a SQL query and data binding. Now each of these DataGridViews will fire a DataBindingComplete event when the binding is done. I have one event handler that handles all of these events. I need a way to know when all of the DataGridViews have finished their data binding, not just any one of them.

Could anyone suggest an elegant way to monitor this?

推荐答案

刷新绑定后(我猜想当您运行查询时),请将绑定计数器重置为0.每个DataBindingComplete事件都更新计数器,如果它等于预期的刷新次数(即绑定的网格数),则执行其他操作.作为设置程序中逻辑的一个属性,这可能会更整洁.您可能需要同步它,但我不这样认为,我认为DataBindingComplete事件在UI线程中运行,因此在管道中运行.
When the binding is refreshed (I guess when you run the query), reset a binding counter to 0. In each of the DataBindingComplete events, update the counter, and if it is equal to the expected number of refreshes (i.e. the number of bound grids), do something else. That would be neater as a property with the logic in the setter, probably. You might need to synchronise it, but I don''t think so, I think DataBindingComplete events run in the UI thread and therefore pipeline.


这篇关于多个DataBindingComplete事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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