AutoComplete TextBox Search From DataBase Table in Using Windows Application C#

AutoComplete TextBox Search DataBase Table in Windows Application

Window Application Search TextBox Related Keyword Display Database Particular Table Record Display In Window Application.

 Auto Suggestion Box Master Page
 Auto Suggestion Box Multiple Table Search
 Auto Suggestion Ajax AutoCompleteExtender
 Auto Complete Search For WINDOW APPLICATION


                    C# Coding

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace WindowsFormsApplication2
    public partial class Form1 : Form

        public Form1()

        SqlConnection con;

        public void dbcon()

    con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\Drizzle\Documents\Visual Studio 2012\WindowsFormsApplication2\WindowsFormsApplication2\Database1.mdf;Integrated Security=True");


        private void Form1_Load(object sender, EventArgs e)
          AutoCompleteStringCollection LocalDataTable = new AutoCompleteStringCollection();

            txtAutoComplete.AutoCompleteMode = AutoCompleteMode.SuggestAppend;

            txtAutoComplete.AutoCompleteSource = AutoCompleteSource.CustomSource;

            txtAutoComplete.AutoCompleteCustomSource = LocalDataTable;


            SqlCommand cmd = new SqlCommand("select countryname from country",con);     
            SqlDataReader rd = cmd.ExecuteReader();         

            if (rd.HasRows == true)

               while (rd.Read())




AutoCompleteMode :  Get & set control Automatic for Textbox

AutoCompleteSource: Get & set the source of complete String

AutoCompleteCustomSource: Get & set the AutoComplete Source 

Property is set to CustomSource

AutoCompleteStringCollection: Get data from Database To allow Bind 

to TextBox.

First - Add the New Window Form - Add the TextBox & Button 

Next - Insert The Values To DataBase Particular Table

Next - Add the  DataBase Connection - To Window Form Publically.

Path - Assign To SqlConnection

Next - Add the Coding For Form _Load  Geting Refresh

Next - Run[F5] The Program 

Textbox  Enter - A - Related CountryName Display From DataBase 

Textbox  Enter - U - Related CountryName Display From DataBase 

Textbox  Enter - I - Related CountryName Display From DataBase 


Post a Comment