Filter Data in Windows Application

Like Web Application it you type a character then all the values will show down of the text box of that perticular character.
here i am giving very good example to filter records in windows application.

Code:
first import these two packages.
Imports System.Data
Imports System.Data.SqlClient

page load you call the below method


Private Sub Intellisense()
Dim con As New SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=MyPractice;Data Source=IT\SQLEXPRESS")
con.Open()
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
daUser.Fill(dsUser)
Dim datacollection As New AutoCompleteStringCollection
For i As Integer = 0 To dsUser.Tables(0).Rows.Count - 1
datacollection.Add(dsUser.Tables(0).Rows(i).Item(1).ToString)
Next
txtUserName.AutoCompleteSource = AutoCompleteSource.CustomSource
txtUserName.AutoCompleteMode = AutoCompleteMode.Suggest
txtUserName.AutoCompleteCustomSource = datacollection

End Sub

Output:Output 2:


Any Doubt Plz post comment i will reply u soon. Santosh,bangalore

2 comments:

  1. pls send the same in C# code

    sudhakarb1238@gmail.com

    ReplyDelete
  2. hi. i am having multiple selections from drop down,based on that selected value i need to show the intellisense.can u help me for this..........

    ReplyDelete