I am using an UltraComboEditor
The UltraComboEditor is linked to a List<> where the DisplayMember is set to "Description" and the ValueMember is Set to "ID"
the ID is an integer and is stored in the relevant field on the table.
the UltraComboEditor is Styled as a DropDown, Autocompletemode = Suggest, AutosuggestFilterMode = Contains, Limit to List = true.
my problem is that when my form is initialised to edit a new record, where the value for the combo box has not yet been set the text of the combobox has defaulted to "0"
This is a pain as and "0" is not in the List and when the user starts to type, they have to delete the "0"
As a work around I set the UltraComboEditor.Text = "" where UltraComboEditor.Text = "0" in the Value_Changed Event, (though this will not work if an entry in the list begins with "0"!)
How can I get the UltraComboEditor to initialise to "" (string.empty) instead of "0"?
How do I submit a feature request?
I want to request that on an UltraComboEditor if LimitToList is set to true, and the control recieves a value not in the list (or null) that you have a choice of behaviours to select;
1) display the value
2) display a default message like "Please select an item from the list" or a user defined message
3) display empty.string
4) display first item in list
sorry but this answer is just ridiculous. No other third party controls or even .net behave this way. If an item is not on the list then the display should just always be an empty string. That's how DevExpress & Janus controls and everyone out there do it. It makes NO sense to make developers write spaghetti code on EVERY form because you cannot conform to standards...
Hi,
There are a number of ways that you could alter the display.
You could use a DrawFilter, which would allow you to override the drawing of the text. You could use a CreationFilter, which would allow you to change the text on the TextUIElement. Or you could try using a DataFilter, which allows you to translate the value from display text to editor value to owner value and vice versa.
The first two will only affect the display and will not have any effect once the control goes into edit mode. The DataFilter might work, but you would have to translate in both direction. So you would handle the EditorToDisplay transition and translate 0 to an empty string and then in the DisplayToEditor, you would do the reverse.
But to be honest, I'm not entirely sure this will work. You might run into a case where the control simply fails to account for the fact that the Value is not on the list when it's not supposed to allow this.
Hi Mike
I see where you are coming from. The alternative could be a variety of things though...
Is it possible to inherit and override the behaviour of the ComboEditor so that if it recieves a value that is not in the list I can specify what text is initially displayed rather than the index itself? (either empty string or a user defined prompt like <Please Select a Value>)
I got the behaviour I needed by getting the ValueChanged event to set the text to "" if the value == 0. Its not as clean a solution as I would like as my form code behind gets cluttered with ValueChanged event handlers
I'm not sure what behavior you are expecting here. If you bind the Value property of the control to an object which returns a 0, the combo has no choice but to display that 0 whether it exists on the list or not. What's the alternative?
You should initialize the value of the initial object you are binding to to a value that exists on the list. Or you could add a 0 item to the list and show an empty string as it's text.
But the combo cannot arbitrarily choose an item from the list. And it cannot arbitrarily translate a 0 into a null because if it tried to save a null to your data source, this would raise an exception.