文本框自动完成功能无效

时间:2016-07-25 11:49:24

标签: c# winforms autocomplete textbox

private  void AutoComplete()
{
    textBox4.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
    textBox4.AutoCompleteSource = AutoCompleteSource.CustomSource;
    AutoCompleteStringCollection col = new AutoCompleteStringCollection();
    OleDbDataAdapter dAdapter2 = new OleDbDataAdapter("select ID from Car ", connParam);
    OleDbCommandBuilder cBuilder2 = new OleDbCommandBuilder(dAdapter2);

    DataTable dataTable2 = new DataTable();
    DataSet ds2 = new DataSet();
    dAdapter2.Fill(dataTable2);
    foreach (DataRow row in dataTable2.Rows)
    {
         //TextBox1.Text = row["ImagePath"].ToString();
         col.Add(row["ID"].ToString());
    }
    textBox4.AutoCompleteCustomSource = col;
}

我在表单加载中调用此函数但不能正常工作

我也在text_change 上调用方法,但我面临同样的问题:没有值出现

0 个答案:

没有答案