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
1475
Multi Select In a WinGrid Cell
posted

Hi-

I have a grid in my form where in, from a particular column the user can select multiple items.So I have a text box with button control set to a win grid having check boxes. One more requirement is some of the rows should be pre-selected based on the values coming from a query from the database. Everything is working fine except when I get duplicate entries from the query. I can't modify the query not to return duplicates. So my problem is, when I get duplicate entries from the query I shouldn't add those to the ValueList property of the cell.

So I wrote a small code to restrict these duplicate entries like the below. But some how Contains method is returning false if it has a value in it.

       If (condition met) Then
                                        If Not v1.ValueListItems.Contains(Value) Then
                                            v1.ValueListItems.Add(Value)
                                        End If
                                    End If

I tried using two overloads that Contains have. e.g. v1.ValueListItems.Contains(New Infragistics.Win.ValueListItem("value")) but still of no use.  Could it be a bug ?

Thanks in advance.

-Swe2.

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    This will not work because Contains checks for an object on the list. It doesn't check properties off those objects. In other words, the ValueListItems collection contains ValueListItems and your Value is probably not a ValueListItem, it's a DataValue of a ValueListItem. So this will never return true, since the list will never contain an object that is not a ValueListItem.

    Cast v1 into an IValueList and you can use the GetText method to find an item on the list with a given DataValue.

Children