检测form内,数据变动

gadev 2009-02-27 11:22:54
可以一个一个判断textchanged,
有没简单一点的方法检测form内,数据变动, 包括datagridview控件

请教
谢谢
...全文
103 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Galllop 2009-02-27
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 supper168 的回复:]
引用 2 楼 cppfaq 的回复:
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…
[/Quote]

这个是焦点检测,没有检测内容变化
Galllop 2009-02-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cppfaq 的回复:]
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 …
[/Quote]


CancelEventHandler ?
CnSharp工作室 2009-02-27
  • 打赏
  • 举报
回复
定义一个对象 保存副本 将对象与控件数据源绑定 控件数据发生异动后 将对象与副本对比
Galllop 2009-02-27
  • 打赏
  • 举报
回复
UP
春天的气息 2009-02-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 cppfaq 的回复:]
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 …
[/Quote]


参考



欢迎加入我的程序设计QQ群80532706哟
cppfaq 2009-02-27
  • 打赏
  • 举报
回复
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...
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);
}
cppfaq 2009-02-27
  • 打赏
  • 举报
回复
把所有需要监测的控件属性CausesValidation设置为true.
然后挂接Form.Validating事件.........

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧