views:

221

answers:

0

VB.NET 2008 .NET 3.5

I hope my title isn't too misleading. I know what the three properties are/do, but have a question about their behavior that led me on a wild goose chase for a while.

I have a DataGridView that is bound to a BindingSource. The BindingSource is bound to a list of complex objects. The DataGridView contains a ComboBoxColumn.

I can get a property for the ValueMember or DisplayMember from deep in the complex object by doing this:

DataGridView.DataMember = "SomeProperty"
DataGridViewComboBoxColumn.ValueMember = "SomeProperty.PropertyToUseForValueMember"
DataGridViewComboBoxColumn.DisplayMember = "SomeProperty.PropertyToUseForDisplayMember"

Notice that the DataMember name must be prefixed to the ValueMember and DisplayMember names. However, when setting the DataPropertyName it must be done like so:

DataGridViewComboBoxColumn.DataPropertyName = "PropertyToUseForDataPropertyName"

Notice that the DataMember name is not prefixed.

Has anyone else run into this? Is it by design for some reason, or is it just confusing?