C#.net 2.0 WinForm TextBox AutoComplete

摘要:C#.net 2.0 WinForm TextBox AutoComplete

在這介紹一個好東西~

於.net2.0中的TextBox其實已經內建AutoComplete的功能~

可於TextBox的屬性頁面中~看到底下三個有關AuotComplete的屬性~如下設定

接下來要如何塞值給他的呢?請參考下面的Code

           tblEmployee employee = new tblEmployee();
            DataTable dt = employee.DoSelect("");

            txtQueryID.AutoCompleteCustomSource.Clear();
            txtQueryName.AutoCompleteCustomSource.Clear();

            foreach (DataRow dr in dt.Rows)
            {
                txtQueryID.AutoCompleteCustomSource.Add(dr["EmpID"].ToString());
                txtQueryName.AutoCompleteCustomSource.Add(dr["EmpName"].ToString());
            }
 

如此一來就實現了AuotComplete的功能了