日期:2014-05-18  浏览次数:20885 次

检测form内,数据变动
可以一个一个判断textchanged,
有没简单一点的方法检测form内,数据变动, 包括datagridview控件

请教
谢谢

------解决方案--------------------
Sorry, it does not work to sink to the form's Validating event.
There is a thread on http://bytes.com/groups/net-vb/362101-how-does-validation-work-winforms discussing the firing of form's Validating event, however, no conlusion was get there.

My next solution would be something like below, however, it's poor anyway, waiting for gurus...
C# code
protected override void OnLoad(EventArgs e) {
            base.OnLoad(e);
            foreach (Control control in Controls) {
                if(control.CausesValidation) {
                    control.Validating += new CancelEventHandler(control_Validating);
                }
            }
        }

        void control_Validating(object sender, CancelEventArgs e)
        {
            Console.WriteLine(sender);
        }

------解决方案--------------------
探讨
Sorry, it does not work to sink to the form's Validating event.
There is a thread on http://bytes.com/groups/net-vb/362101-how-does-validation-work-winforms discussing the firing of form's Validating event, however, no conlusion was get there.

My next solution would be something like below, however, it's poor anyway, waiting for gurus...

C# codeprotected override void OnLoad(EventArgs …

------解决方案--------------------
探讨
引用:
Sorry, it does not work to sink to the form's Validating event.
There is a thread on http://bytes.com/groups/net-vb/362101-how-does-validation-work-winforms discussing the firing of form's Validating event, however, no conlusion was get there.

My next solution would be something like below, however, it's poor anyway, waiting for gurus...

C# codeprotected overr…