WinForm Databinding Doesn’t Work With Nullable

There are some major issues using databinding in WinForm apps when using nullable<t>.  The first problem I uncovered was a with a nullable datetime.  There is no native support for binding a DateTimePicker to a Nullable<DateTime>.  There are a few blog posts about workarounds on this topic but they are workarounds.

Then I uncovered issues binding a TextBox to a Nullable<int>.  The problem is once a value was set I couldn’t figure out how to set value back to null.

The next issue was with binding a ComboBox to a Nullable<int>.  To test I bound the ComboBox to a int and I didn’t have any issues.

Seems like the WinForm team needs to do some cleanup work for the features introduced in .Net 2.0.  I suspect that won’t happen though, MSFT appears to have already moved on to WPF.

I wish I could attach a demo app to this post…

LiveJournal Tags: ,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s