Filtering a DataGridView

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2006
Posts: 23
Reputation: furjaw is an unknown quantity at this point 
Solved Threads: 0
furjaw furjaw is offline Offline
Newbie Poster

Filtering a DataGridView

 
0
  #1
Nov 6th, 2007
Visual Basic.Net:

I have a DataGridView in Last Name sequence.
Is it possible to when a user types the first letter of a last name
that it displays all rows with last names that start with that letter.
When he types the second letter, it displays all records whose last name starts with those 2 letters, etc.?
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: Filtering a DataGridView

 
0
  #2
Nov 6th, 2007
This is pretty much doable and this functionality is called AutoComplete is Web Platform and Incremental Search in WinForms Arena.
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 23
Reputation: furjaw is an unknown quantity at this point 
Solved Threads: 0
furjaw furjaw is offline Offline
Newbie Poster

Re: Filtering a DataGridView

 
0
  #3
Nov 6th, 2007
It works great!!!
Below is the code that I ended up with:

If LastNameTextBox.TextLength > 0 Then
PatientBindingSource.Filter = String.Format("LastName Like '" & LastNameTextBox.Text) & "*'"
Else
PatientBindingSource.Filter = String.Empty
End If
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: Filtering a DataGridView

 
0
  #4
Nov 6th, 2007
What event of the textbox did you use?
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 23
Reputation: furjaw is an unknown quantity at this point 
Solved Threads: 0
furjaw furjaw is offline Offline
Newbie Poster

Re: Filtering a DataGridView

 
0
  #5
Nov 6th, 2007
Private Sub LastNameTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LastNameTextBox.TextChanged
Reply With Quote Quick reply to this message  
Join Date: Dec 2006
Posts: 645
Reputation: binoj_daniel is an unknown quantity at this point 
Solved Threads: 17
binoj_daniel's Avatar
binoj_daniel binoj_daniel is offline Offline
DaniWeb Expert

Re: Filtering a DataGridView

 
0
  #6
Nov 6th, 2007
Thats good, glad you solved it. you can read more .net articles & best professional best practices here
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 1
Reputation: iloire is an unknown quantity at this point 
Solved Threads: 0
iloire iloire is offline Offline
Newbie Poster

Re: Filtering a DataGridView

 
0
  #7
Dec 4th, 2008
Hi guys, there is an example of code posted of exactly that you want to do (it evens uses the First Name field and does "on the fly data filtering" based on filter condition)

You may see it in action here:

Dynamic filtering DataGridView in C#
http://www.dotneat.net/2008/12/03/Dy...teringInC.aspx

(Windows Forms and C#)
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 8788 | Replies: 6
Thread Tools Search this Thread



Tag cloud for VB.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC