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.?

Recommended Answers

All 9 Replies

This is pretty much doable and this functionality is called AutoComplete is Web Platform and Incremental Search in WinForms Arena.

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

What event of the textbox did you use?

Private Sub LastNameTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles LastNameTextBox.TextChanged

Thats good, glad you solved it. you can read more .net articles & best professional best practices here

hi, there.. i try used your code, but it doesn't help...


If LastNameTextBox.TextLength > 0 Then
PatientBindingSource.Filter = String.Format(

Use % sign on both side of given string.

If LastNameTextBox.TextLength > 0 Then
PatientBindingSource.Filter = String.Format("LastName Like '%" & LastNameTextBox.Text) & "%'"
Else
PatientBindingSource.Filter = String.Empty
End If
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.