Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > DataGridViewComboBoxCell conditional dropdown displaying ValueMember not Displaymember
 

DataGridViewComboBoxCell conditional dropdown displaying ValueMember not Displaymember

I am trying to create a DataGriodViewComboBoxColumn where the items in each row are filtered by another value in the row.

I see lots of posts that say bind the dropdown data to the column and then add a filter when the EdiotingControlShowing event occurs and remove it on the CellEndEdit event.

But this doesn't cover the initial paint of the display where the data comes from a bound data source.

I have tried setting individual item sets on each row when the OnRowAdded event goes off but now I am getting strange behaviour. The dropdown items are set correctly but the FormattedValue for the ComboBoxCell is taken from ValueMember not DisplayMember.

I.e. ValueMember is a set of id numbers and DisplayMember is the corresponding set of names.

When I open the dropdown I see the DisplayMember items but when I select one it is the corresponding ValueMember value that gets shown.

Does anyone have an idea why this is so. Or a good way to create a conditional dropdown per row?

DGMoffat  Monday, July 07, 2008 7:56 PM

Hi DGMoffat,

> Does anyone have an idea why this is so.

You have mentioned your solution is to set individual item on each row when the OnRowAdded event goes off and then the problem appears.

Could you please send me a simple project that could just reproduce the problem? To get my actual email address, remove 'online' from my displayed email address.

> Or a good way to create a conditional dropdown per row?

IMO, a good way is to handle the EditingControlShowing event of the DataGridView and then set or filter the drop down list of the hosted combobox.

Thanks,

Linda

Linda Liu  Thursday, July 10, 2008 1:11 AM

You can use google to search for other answers

Custom Search

More Threads

• some of my class<T>'s members don't turn up on datagridview bound to BindingList<T>
• BindingSource.Filter
• Mailing Concept
• Parameterized SQL
• Handling Null data items from an Access database
• Sortable Column in DataGridView with Objiect based DataSource
• DataGridView: Maintaining style while fetching new rows from underlying data.
• adding controls in datatable
• Adding Multiple column headers for datagridview Control
• Parent Child objects binding to datagridview