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?