We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

ValueMember Being Displayed in ComboBox Cell

I''ve got a GridControl (v3.3.0.0) in which I set a certain column''s CellType to "ComboBox". I then set the DataSource property for the cell to a custom, strongly-typed collection of custom objects. If I just set the DisplayMember property of the column to one of the members of the objects in the collection, the appropriate text is displayed in the drop-down list. However, if I also set the column''s ValueMember property, the dropdown list starts showing the ValueMember values instead of the DisplayMember values. To describe this in other words using an example, I have a combobox cell whose DataSource is set to a collection of People. I set the DisplayMember to "FirstName" and it displays the first name of all people in the list. If I then also set ValueMember to "ID", the people''s first names are no longer displayed in the list. Instead the people''s IDs are displayed. This doesn''t seem right. Is this a known bug?

4 Replies

MS Maxim Software Systems February 15, 2006 05:24 PM UTC

Is this issue being looked into?


KI Kingsley February 15, 2006 08:15 PM UTC

Did you set the MappingName property? I''m doing something similar successfully by setting MappingName and ValueMember to ID; then set DisplayMember to FirstName. Good luck


MS Maxim Software Systems February 15, 2006 08:27 PM UTC

There does not appear to be a MappingName property on the ColumnStyle class. What''s really strange is that this is actually working for one dropdown list on the grid, but not the other two. I can''t for the life of me figure out why.


MS Maxim Software Systems February 15, 2006 08:42 PM UTC

I discovered what was causing the problem. I didn''t realize at the time that the class member whose name I was putting in the DisplayMember property of the column style had optional parameters in it. When I tried another property that did not have any optional parameters, it worked. What was also confusing me was that the ToString method of my class was returning the same thing as the member with the optional parameters, so it *looked* like the whole thing was working when I did not specify the ValueMember for the column style. I''m guessing the combobox uses the ToString method by default to determine what to display if the DisplayMember property of the column style is invalid. If the ValueMember is specified in that same case, then the combobox uses the ValueMember property instead. Anyway, the problem has been identified and I can now solve it. Thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon