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
390
Ultracombo selects the wrong value with identical names
posted

I've got an UltraCombo thats filled with Product Objects, these objects have a Customer object as a property (the foreign key). 2 of these products have their Name property set with an identical value.

The value's look like this:

Customer            Product name

DNM1                   HRT

DNM2                   HRT

 

Now i try to set the selected value like this:

cboProduct.Value = product;

Product here is the DNM2/HRT object. Now when i debug this it appears to work fine. cboProduct.Value contains the right value. However when i do the following:

(Product)cboProduct.SelectedRow.ListObject;

It returns DNM1/HRT which is incorrect. The weird thing is when i actually use the ComboBox and select the right value by hand then it returns the correct value. I've also tried to loop through all the rows and set the Selected property to true but that gives the same result.

Instead of retreiving the ListObject value i tried to access the Value like this:

(Product)cboProduct.Value;

This works fine when setting the value in the code. However when i then set it by hand it gives back the string of the name instead of the Product Object.

I do override the ToString() method of the Product Object but removing that didn't change a thing. Same thing goes for the DisplayMember property of the Combobox. Its set to Name now but removing that didn't help either.

In short there are 2 things that i do not understand at all:

- Why does ListObject give me back the wrong value even though i selected the right one, what so different about selecting the value by hand?

- Why does the Value ever change to a string when the ComboBox holds Product Objects?

Parents
  • 469350
    Suggested Answer
    Offline posted

    What version of the controls are you using?

    Does setting the Value to anything update the SelectedRow? Does this work for any value? If this works for other values and not for this one case where the text is the same, then it sounds like a bug to me. But I'm not sure that the SelectedRow is updated at all when you set the Value. It might not be updated until the list is dropped down. After all, there is really no reason for the SelectedRow to be updated unless the user can see the list.

    If I am wrong and this works for other values, then it's probably a bug, in which case we will need a small sample project demonstrating this so we can check it out and get it fixed.

    Either way, you could probably get around it by casting the UltraCombo into an IValueList. Then you can use the GetTextMethod to find the row associated with the Value you want and get the correct row.

     

Reply Children
No Data