Filter Data(Auto Completion) in Windows Application

Posted by Santosh4u under Windows Forms category on | Views : 2064
Introduction :
Like Web Application it you type a character then all the values will show below of the text box for that perticular character.
Description :
if you type 'sa' in the textbox then two Names 'santosh' and 'sanjib' will show below of the textbox because both letter is contains 'sa' from start.

here i am giving very good example to filter records in windows application.

page load you call the Intellisense method written below.
Imports System.Data
Imports System.Data.SqlClient
Private Sub Intellisense()
Dim con As New SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyPractice;Data Source=IT\SQLEXPRESS")
Dim dsUser As New DataSet
Dim daUser As New SqlDataAdapter
Dim com As New SqlCommand
com.Connection = con
com.CommandText = "SELECT * FROM tbUSERMST"
daUser.SelectCommand = com
Dim datacollection As New AutoCompleteStringCollection
For i As Integer = 0 To dsUser.Tables(0).Rows.Count - 1
txtUserName.AutoCompleteSource = AutoCompleteSource.CustomSource
txtUserName.AutoCompleteMode = AutoCompleteMode.Suggest
txtUserName.AutoCompleteCustomSource = datacollection
End Sub

Comments or Responses

Login to post response