Naz
Naz

Reputation: 5144

Winforms binding to null property

I am using EF/POCO objects and when binding textbox to nullable double some strange things happen. After I enter values and change focus to the next one the value in the box I just edited clears out. I bind my properties like this:

distanceTextEdit.DataBindings.Add("Text",
                                _routeControlVM.Route,
                                "Distance",
                                false,
                                DataSourceUpdateMode.OnPropertyChanged,
                                string.Empty);

What could cause this behavior ?

EDIT: Ok. Problem was in API of the DataBindings. I just changed false to true and everything works now.

Upvotes: 4

Views: 1134

Answers (1)

Teoman Soygul
Teoman Soygul

Reputation: 25742

The data must be formatted before it can be bound to nullable properties where I see that you are disabling it exclusively. Try with formatting enabled.

EDIT: I've just noticed you already enabled formatting with DataBindings.Add(.., .., .., true, ..);

Upvotes: 4

Related Questions