Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data-bound TextBox: can't exit

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.

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")

Any suggestions?

like image 904
Muxa Avatar asked Oct 20 '08 09:10

Muxa


1 Answers

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

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

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).

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

like image 167
orj Avatar answered Sep 20 '22 11:09

orj