.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Filter Data(Auto Completion) in Windows Application

Posted By:Santosh       Posted Date: October 18, 2009    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  
 

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:
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")

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:

More Details plz follow
http://santoshdotnetarena.blogspot.com/

Regards
Santosh


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend