public string strConnection = ConfigurationManager.ConnectionStrings["MySqlConnectionString"].ConnectionString.ToString(); AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection(); public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { MySqlDataReader dReader; MySqlConnection conn = new MySqlConnection(); conn.ConnectionString = strConnection; MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conn; cmd.CommandText = "select name from VDCMunicipalityInfo"; conn.Open(); dReader = cmd.ExecuteReader(); if (dReader.HasRows == true) { while (dReader.Read()) namesCollection.Add(dReader["name"].ToString()); } else { MessageBox.Show("Data not found"); } dReader.Close(); txtName.AutoCompleteMode = AutoCompleteMode.Suggest; txtName.AutoCompleteSource = AutoCompleteSource.CustomSource; txtName.AutoCompleteCustomSource = namesCollection; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)