DataSource, ValueMember and DisplayMember Order Issues

For two times in a row this week I was asked to do a buddy check of .NET code that performs databinding. I found out that the order of the binding operations is very important:

  • Set the DisplayMember and/or ValueMember first
  • Set the DataSource property after that

You will avoid many exceptions this way 😉

RESOURCES
Scott McMaster at CodeProject has more information regarding this weird databinding Windows Forms issue.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.