数据绑定的TextBox:不能退出 [英] Data-bound TextBox: can't exit

查看:86
本文介绍了数据绑定的TextBox:不能退出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框绑定到一个对象的一种形式的财产(其实几个文本框)。本作是一个编辑的对象。当我编辑一些对象,并在文本框中一个修正值,我不能退出文本框(既不是标签,也没有点击另一个文本框)。但是这并非总是如此 - 编辑(同类型),当其他物体正常工作

I've got a text box bound to an object's property (in fact several text boxes) on a form. This for is an editor for an object. When i'm editing some objects and modify values in the one of the text boxes i can't exit from the text box (neither by tab nor clicking on another text box). However that's not always the case - when editing other objects (of the same type) it works fine.

下面是一个code snipet:

Here's a code snipet:

txtValue.DataBindings.Add("Text", _SourceObject, "PlannedValue", True, DataSourceUpdateMode.OnPropertyChanged, Nothing, "c")
txtEstPlacements.DataBindings.Add("Text", _SourceObject, "EstimatedPlacementCount")
txtReference.DataBindings.Add("Text", _SourceObject, "Reference")

有什么建议?

推荐答案

听起来像是一个数据验证问题。检查窗体上的控件有自己的CausesValidation属性设置为true或false。

Sounds like a data validation issue. Check if the controls on the form have their CausesValidation properties set to true or false.

另外,还要检查表格上的AutoValidate财产。这可能是设置为启用preventFocusChange(这是默认值)。

Also check the AutoValidate property on the form. It is probably set to EnablePreventFocusChange (which is the default).

有也可以是供给在文本框中的值不能转化为它被绑定到的源数据对象的属性的类型的情况。我相信Convert类用于此(虽然我可能是错在这里)。

It may also be the case that the value being supplied in the text box can not be converted to the type of the property it is bound to on the source data object. I believe the Convert class is used for this (though I may be wrong here).

您可能想看看 MSDN上的这篇文章覆盖的WinForms验证的一些细节。

You may want to check out this article on MSDN that covers winforms validation in some detail.

这篇关于数据绑定的TextBox:不能退出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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