更新绑定数据源后立即引发什么文本框事件?
在Windows表单中,当我从文本框中选出时,将更新界限的数据源值。我想在数据源更改之前和立即捕获事件。我认为Onleave活动是我想要的事件。在调试器中,我没有看到数据源值更改。但是,在事后我可以做什么活动?
In windows forms, when I tab out of a text box, the bound data source value is updated. I'd like to capture the events right before and right after the data source changed. I think the OnLeave event is what I want for the before event. In the debugger, I'm not seeing the data source value changed. But, what event can I key off of for the after event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为没有一个事件完全符合您的要求,我认为您最接近的是使用
DataBindings
并找到您的特定Binding 并且您可以捕获
Parse
事件。但我相信此事件在数据被推回到源之前触发,因此它并不比LostFocus
事件好多少。I don't think there is an event that does exactly what you're asking, the closest I think you're going to get is to use the
DataBindings
and find your specificBinding
and the you can catch theParse
event. But I believe this event fires before the data is pushed back to the source, so it's not much better than theLostFocus
event.TextBox DataBindings的默认事件是
DataSourceUpDateMode.OnValidation
。当您从文本框中选出时,以下事件将触发:验证
事件具有canceleventargs
参数,允许您取消WEFT尝试文本框(焦点将保留在文本框中)。如果您使用
datasourceupdatemode.onpropertychanged
,它将使用每个键或文本更改更新数据源。The default event for TextBox DataBindings is
DataSourceUpdateMode.OnValidation
. When you tab out of the TextBox, the following events will fire:The
Validating
event has aCancelEventArgs
parameter that allows you to cancel the leave attempt for the TextBox (the focus will remain in the TextBox).If you use
DataSourceUpdateMode.OnPropertyChanged
, it will update the data source with every keystroke or text change.