Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Filter for ICollectionView

12 views
Skip to first unread message

Hoser

unread,
Oct 27, 2007, 6:00:01 PM10/27/07
to
Does anyone out there have an example of adding a filter to a collectionview
in vb.net language. Everything I see is in C#.

Regards

Hoser

unread,
Oct 27, 2007, 9:35:00 PM10/27/07
to
I figured it out, Maybe my own answer will help others:

Partial Public Class ProductForm
Public Sub New()
MyBase.New()
Me.InitializeComponent()
Dim view As ICollectionView =
CollectionViewSource.GetDefaultView(ProductDetail.DataContext)
'view.SortDescriptions.Add(New SortDescription("PInstaller",
ListSortDirection.Ascending))

view.Filter = New Predicate(Of Object)(AddressOf Contains)


' Insert code required on object creation below this point.
End Sub
Public Function Contains(ByVal de As Object) As Boolean
Dim order1 As Products = TryCast(de, Products)
Return (order1.PInstaller = "John Doe")
End Function

Trevor Eaton

unread,
Oct 19, 2010, 9:17:08 AM10/19/10
to
i know this is an old thread but hopefully somebody will reply - when i use your code, i get "Type Products is not defined"

any suggestions?


> On Saturday, October 27, 2007 6:00 PM Hose wrote:

> Does anyone out there have an example of adding a filter to a collectionview
> in vb.net language. Everything I see is in C#.
>
> Regards


>> On Saturday, October 27, 2007 9:35 PM Hose wrote:

>> I figured it out, Maybe my own answer will help others:
>>
>> Partial Public Class ProductForm
>> Public Sub New()
>> MyBase.New()
>> Me.InitializeComponent()
>> Dim view As ICollectionView =
>> CollectionViewSource.GetDefaultView(ProductDetail.DataContext)
>> 'view.SortDescriptions.Add(New SortDescription("PInstaller",
>> ListSortDirection.Ascending))
>>
>> view.Filter = New Predicate(Of Object)(AddressOf Contains)
>>
>>
>> ' Insert code required on object creation below this point.
>> End Sub
>> Public Function Contains(ByVal de As Object) As Boolean
>> Dim order1 As Products = TryCast(de, Products)
>> Return (order1.PInstaller = "John Doe")
>> End Function
>>
>> "Hoser" wrote:


>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>> Search Scope for SharePoint Web Site
>> http://www.eggheadcafe.com/tutorials/aspnet/d80e1642-9c87-4e05-b726-fae3e2b60d12/search-scope-for-sharepoint-web-site.aspx

0 new messages