Hi,
Can any one tell me y contain method of ValueListItem does not work. I am trying to find a valuelistitem using
this
.ultraGrid2.DisplayLayout.ValueLists[MyValueList].ValueListItems.Contains(v1) where v1 is ValueListItem but it always gives me false.
While the same works fine if add any new valuelistitem and then try to find it.
ValueListItem.Remove() also works fine but not contain().
Please Help.
The only explanation I can think of is that the item is not in the collection. The Contains method will do a reference comparison, so if you create a ValueListItem instance with the same DataValue and DisplayText as one that exists in the collection, and pass that into the Contains method, it should not and does not return true since they are two different instances.
I am also having a problem with the Infragistics ValueListItems.Contains method not working.
If I run the following code, after having added a ValueListItem called 'Test' - If grdData.DisplayLayout.ValueLists.Contains("Test") ..., this return False
If I then try to add it again - grdData.DisplayLayout.ValueLists.Add("Test") - I get an error stating the key already exists.
Can you provide an example of how this should work?
Thanks
Andrew Hunot
Hello Andrew,
Could you please try passing the object itself to the 'Contains()' method and test this again.
Sorry but I don't understand.
If I try to create an object with the same key and then test 'Contains()' it returns false as it is a new object.
Is it possible to send me some example code?
Many thanks for the speedy reply.
Regards
Andrew
Andrew,
Contains checks if the collection has the specified 'ValueList' object. There isn't any overload which takes a string.