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.
Unfortunately, activation email could not send to your email. Please try again.

ValueMember Being Displayed in ComboBox Cell

Thread ID:

Created:

Updated:

Platform:

Replies:

40834 Feb 14,2006 02:39 PM Feb 15,2006 03:42 PM Windows Forms 4
loading
Tags: GridControl
Maxim Software Systems
Asked On February 14, 2006 02:39 PM

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?

Maxim Software Systems
Replied On February 15, 2006 12:24 PM

Is this issue being looked into?

Kingsley
Replied On February 15, 2006 03:15 PM

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

Maxim Software Systems
Replied On February 15, 2006 03:27 PM

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.

Maxim Software Systems
Replied On February 15, 2006 03:42 PM

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!

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;