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.

A non-exclusive combo box using a Data Source

Thread ID:

Created:

Updated:

Platform:

Replies:

4199 May 2,2003 09:39 AM May 2,2003 03:19 PM Windows Forms 3
loading
Tags: GridControl
Brenda Maloff
Asked On May 2, 2003 09:39 AM

I have a grid with a combo box on it that has ExclusiveChoice set to false. I'm binding this to a data table with the DataSource and I have a DisplayMember column that is a string and a ValueMember column that is an int. Now when I'm using this combo box, if I select a value out of the list, I'm fine. However when I type in a value not in the list and then leave the cell, the cell appears as if the text is doubled up and offset. If the ValueMember column is a string I do not get this behavior. Is there a way that I can leave the ValueMember column as an int and not get this weird looking text happening when I type in a value that is not in the list?

Administrator [Syncfusion]
Replied On May 2, 2003 10:28 AM

What is the CellValueType of that column? Can you make it be typeof(string)? One reason you might get this shadowed text is because the grid tries to convert the text to an int and that fails. Stefan

Brenda Maloff
Replied On May 2, 2003 11:23 AM

I know the reason I'm getting shadowed text is because of the conversion...if I enter "123" I'm fine, but if I enter "abc" I get the shadowed text. I tried making the CellValueType of type string but to no avail, I get the same thing happening.

Administrator [Syncfusion]
Replied On May 2, 2003 03:19 PM

One way you can do this is to dynamically add new entries to the datasource of the combobox. You can do this in CurrentCellValidating. In your handler, you can check if the new value is not a number. If it is not, check the datasource to see if the new item is in the displaymember. If it is not, add it to the datatable. Attached is a little sample. With the upcoming 1.6 release, there are formatting events that you could handle and probably avoid this problem without having to dynamically build your comboboxes data source.

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.

;