Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
2549
UltraComboEditor, ValueList, how to set the selected item
posted

Hi all,
I am facing a strange problem (I am kindof sure that I overlook something).
I have an UltraComboEditor and I set its ValueList property to a valuelist.
I use an enumerator to create the valuelist setting the DataValue to its integer representation and its DisplayText to the textual representation of each enumerator value.

I use this quite a lot in UltraGrids and normally it works like a charm.

Also the UltraComboEditor shows the correct text and by debugging it I can see that its DataValue is also correctly set.

What I am unable to do is to set the SelectedItem property for the UltraComboEditor.
I tried it like this:

cmbAccountType.SelectedItem = 
cmbAccountType.ValueList.ValueListItems
.Cast<ValueListItem>()
.First(f => Convert.ToInt32(f.DataValue) == 0);

but it tells me that the conversation between onbject and integer ist not allowed.
Also if I am stepping into thie lambda expression I can see that f.DataValue is an object and that f.DataValue.DataValue contains the actual integer value. But I can not get to this...

How should I set the value (I only got the integer because the textual representation is created through localizing the enum) in an easy way?

Any help (and enlightment) is kindly appreciated,
cheers
Andy

  • 2549
    Suggested Answer
    posted

    I figured it out,
    there was an error in the code that generates the ValueLists from enums,
    everything is fine now.

    cheers
    Andy