I am having problems with a basic functionality: I am trying to set the value of an UltraComboEditor in code and the combo is reading the int value as a string and not changing the displayed value to the related display member text. The combo is bound to a dataset for its list items but is not binded to any underlying record field. So with:
mycombo.DataMember = "MyIntID";mycombo.DisplayMember = "MyStringField";mycombo.SetDataBinding(MyDataTable, "");
this displays the list OK. Now, in code after some other field is changed:
mycombo.Value = MyInt;
After this, mycombo displays the number of MyInt and not the related string display member. Also, mycombo.Value shows "10" when the MyInt ==10 (that is to say, the string value.
If I bind the combo to an underlying field, all workds:
mycombo.DataBindings.Add(new Binding("Value", MyDataSet,"MyTable.MyFieldID"));
Now when the record changes, the correct display member is displayed and the mycombo.Value property shows an int and not the string value, e.g., mycombo.Value shows 10 and not "10".
To recap: I want to have an combo that's dropdown is filled with a dataset, but the combo is not bound to any record field; then I want to change the display value in the list in code by setting the Value or whatever field is appropriate with the integer ID of the DisplayMember's key.
Thanks.
Hello Mike
yes, your description is right, my "default" value is null though, so it reverts back to null after focus is lost.
For this particular case we decided to cut the combo from the ui for now, but there will be more use cases in which we will definitly use this kind of binding very soon.
I will look at your sample and search around for more general help then. Thanks for your deep investigation!
Blue
Hi Blue,
I tried this out and I am seeing a problem. I'm not sure it's the same thing you are seeing, though.
Basically, the ValueMember on the list is a Long (Id) and the Value property of the control is bound to a Long? (nullableId). If I drop down the list and pick something, it seems to work fine, but then as soon as I lose focus on the control, it reverts to the original value.
Is that the behavior you are getting?
I am attaching my sample here so you can check it out and see if you get the same results.
In any case, this appears to be a bug or some quirky behavior in the DotNet BindingManager and not in the UltraCombo. I tried the same thing using the Inbox ComboBox control (as you can see in my sample) and I get exactly the same results.
I tried to see if I could get it work by handling the Parse event of the Binding and handling the conversion from long to long? myself, but I could not get this to work. Since the same problem exists with the inbox controls, tough, I imagine you are not the first person to encounter this, so maybe there is more information on MSDN or perhaps you could investigate this on a more general Microsoft DotNet forum.
Hello,
ok updated from 2010.3.2094 to 2128 now...
I am quite sure I set up the databindings just as you described. I also double-checked everything.
No success. :(
before I try to build a sample, here is what is of importance for you to get an idea what I do:
UltraCombo.DisplayMember: "Name" (string)
UltraCombo.DropDownStyle = DropDownList
UltraCombo.ValueMember: "ID" (long)
uiLanguageListBindingSource.DataSource = a list with BOs (ID (long), SourceLanguageID (long?) and Name (string) properties)
UltraCombo.DataBindings.Add("Value", this.uiLanguageEditBindingSource.DataSource, "SourceLanguageID");
Property SourceLanguageID is long? (NULLABLE!)
UltraCombo.SetDataBinding(this.uiLanguageListBindingSource, null, true);
The UltraCombo has 1 Column (Key = "Name"), DataType is "string" (changing this does not effect anything)
as you can see, I am binding a list of BOs. The UltraCombo is meant to display a nullable property of the same type of the BO.
really nothing special i think... :)
If this is too confusing, I will try to find some free time to create a simple example.
This is most likely either a bug in the version of the control you are using or else your data types aren't matching up. If the Value property of the control is bound to a Nullable Integer, then you must make sure that your ValueMember column is also an Integer or Nullable Integer.
If that does not help, then you might just need to get the latest service release.
How to get the latest service release - Infragistics Community
If that doesn't help, then see if you can post a small sample project demonstrating the behavior you are getting and I will be happy to take a look at it for you.
I got the same problem
my UltraCombo is databound to a list of BOs
i bind the ultracombo's Value property to a property of type long? (nullable) (DataBindings.Add(...))
in the ui selecting a row from the dropdownlist will clear the selection after focus of the ultracombo is lost. :(
the nullable property's value of the bound BO will remain null forever.
need advise :)