I am binding my value list to a DataTable. In order to provide the user with a blank line, I add a row to the DataTable where all the fields are an empty string except the value field is a 0. When the user selects a value and then tries to change it back to the blank value, as soon as they tab out of the field, the original value is selected.
There is a way to owner draw the items; you handle the ValueList's DrawValueListItem event, and in this case, when the ValueListItem's DisplayText is null or empty, set the DoDefaultDrawing property of the event arguments to true, and nothing will be drawn for that item.
Thanks for the information, Brian!
I do feel that this is a limitation in the control. Having the ability to leave a non-required field blank is a common scenario and it's a little awkward for users when they are tabbing through data entry feilds and there is a 1 character space in there. However, it shouldn't be too difficult to work around this and I'm hoping to hide it from the user now that I know exactly what's going on.
shmuly said: Problem 1 - The value shows up as 0 in the combo. I was able to overcome this by setting the DisplayStyle of the value list to Text. In my opinion this is a mistake in the control. If I set an empty string, it should show. Using reflector, I was able to see that it's treating empty string and Null the same. Problem 2 - If the display field is set to an empty string, once I select a real value, I cannot select the empty string. The control tries to interpert it as a number and c***a format exception.
Problem 1 - The value shows up as 0 in the combo. I was able to overcome this by setting the DisplayStyle of the value list to Text. In my opinion this is a mistake in the control. If I set an empty string, it should show. Using reflector, I was able to see that it's treating empty string and Null the same.
Problem 2 - If the display field is set to an empty string, once I select a real value, I cannot select the empty string. The control tries to interpert it as a number and c***a format exception.
The Infragistics.Win.ValueListItem class (which encapsulates the items displayed by the UltraComboEditor) exposes two properties, DataValue and DisplayText. The former is of type object, the latter of type string. When you don't specify a value for the DisplayText property, the ToString() method (of the object the DataValue property references) is called to determine what to display. Setting the DisplayText property to either null or an empty string will cause the string representation of the DataValue to be used; an item's resolved text can never be an empty string.
Hi,
I tried to set up a sample using your code here and it seems to work perfectly fine for me. What do I need to do to get a problem to occur? It does not appears that this code is using any nullable types, either, so I'm really not sure how that comes into it.
Mike,
Try this:
Create a class/object in vb.net with these two properties:
Public
Property Code() As Integer
Property Text() As System.String
Put a combo editor on a form and fill it like this:
Dim
lst As New List(Of CodeObject)
Dim Code1 As New CodeObject(0, "")
lst.Add(Code1)
Dim Code2 As New CodeObject(1, "test 1")
lst.Add(Code2)
Dim Code3 As New CodeObject(2, "test 2")
lst.Add(Code3)
The only way I'm able to work around this is to feed my object list into a custom code class that uses a string as the code property and I must set the displaymember of the 'blank row' at least 1 character wide.