 
 
Otomatik Kelime Tamamlama
Merhaba arkadaşlar. Bu makalemizde Google arama motorundaki gibi Textbox a girilen kelimeyi otomatik olarak tamamlatacağız. TextBox nesnesinin AutoCompleteMode u SuggestAppend ve AutoCompleteSource uda CustomeSource olarak seçin (Şekil 1).



Form1.cs
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
           SqlConnection baglan = new SqlConnection("Data Source=(LocalDB)\\v11.0;AttachDbFilename=|DataDirectory|\\info.mdf;Integrated Security=True;Connect Timeout=30");
            SqlCommand komut = new SqlCommand("Select Ad From [dbo].[Table]", baglan);
            baglan.Open();
            SqlDataReader reader = komut.ExecuteReader();
            AutoCompleteStringCollection MyCollection = new AutoCompleteStringCollection();
            while (reader.Read())
            {
                MyCollection.Add(reader.GetString(0));
            }
            textBox1.AutoCompleteCustomSource = MyCollection;
                
           baglan.Close();
           
        }
       
    }
}
Bir makalenin daha sonuna geldik. Bir sonraki makalede görüşmek dileğiyle. Hoşçakalın. Bahadır ŞAHİN