tags:

views:

54

answers:

2

Hello

I have this lambda expression

Me.SubcriperGrd.ItemsSource = _
   source.Where(Function(p As subscripers) p.Navn Like navn)

where i should filter the grid data based on the typed input in a txtbox

It returns the result when i type the full name but it doesn't filter the data as i type along in the txt field

what am i missing ?

Thanks

+1  A: 

You're probably missing responding to the event sent when the text changes TextBox.TextChanged. Handle this event and update the filter each time the text changes.

Jason
Hello and thank you for the replythe text changed is firring when i do type along in the txtbox Private Sub cmdsearch(ByVal sender as Object, ByVal e as System.Windows.Controls.TextChangedEventArgs) Dim navn As String = DirectCast(Me.txtsearch.Text, String) 'convert our name collection to an IEnumerable(Of T) where T (type) = Person Dim source As IEnumerable(Of subscripers) = DirectCast(_SubscriperContext.subscripers, IEnumerable(Of subscripers)) Me.SubcriperGrd.ItemsSource = source.Where(Function(p As subscripers) p.Navn Like navn) End Sub
hmm strange how its formatted Private Sub cmdsearch(ByVal sender as Object, ByVal e as System.Windows.Controls.TextChangedEventArgs) Dim navn As String = DirectCast(Me.txtsearch.Text, String) Dim source As IEnumerable(Of subscripers) = DirectCast(_SubscriperContext.subscripers, IEnumerable(Of subscripers)) Me.SubcriperGrd.ItemsSource = source.Where(Function(p As subscripers) p.Navn Like navn) End Sub
I wasn't familiar with VB.NET's `Like` operator so I looked it up in the docs in MSDN (http://msdn.microsoft.com/en-us/library/swf8kaxw.aspx). I think that this is not the tool for the job as it appears to be for pattern matching (a very bare bones regex if you will). I think that you want `p.Navn.StartsWith(navn)`.
Jason
Oh, looks like you already figured that out.
Jason
Hi Jason Thanks for your reply - you were the only one in this thread who actually offered serious assistance. Thank you for your effort and time
@vbturbo: It's my pleasure. "and ill not bother the stack overflow forum ever again." Meh, ignore those that don't take you seriously; there's plenty of folks here that will. Just ask clear questions that haven't already been answered and there are plenty of people that will try to help you out. Good luck.
Jason
+1  A: 

Sorry for asking (seems like i must be a jerk according to some of the response)

here is the solution

Me.SubcriperGrd.ItemsSource = source.Where(Function(p As subscripers) p.Navn.StartsWith(navn))

in case someone else might look for a filter solution

and ill not bother the stack overflow forum ever again

Nah, it just sounds funny => "lambada expressions" instead of "lambda expressions". Can't tell about others but I didn't want to offend you in any way. Welcome aboard and DO bother stack overflow forum again. It's a great resource to simplify your everyday development process. :)
Arnis L.