3

我希望这将是一个共同的需求。任何人都可以帮助或将我指向解释如何执行此操作的页面吗?

4

2 回答 2

2

如果您的意思是 上的自动完成选项TextBox,我不知道对此有任何内置支持。最接近的(虽然不一样)是使用DataGridViewComboBoxColumn.

对于不能直接获得的东西;看起来其他人已经看过这个 - 你可以试试这里的示例。

于 2009-03-23T08:18:52.157 回答
0

如果您的意思是使用文本框按钮 textChanged 事件从数据库中获取 dataGridView 的数据,请执行此操作。

private void textBox1_TextChanged(object sender, EventArgs e)
{
string query = "select Emp_ID,Emp_Name,Father_Name,Email from Employee where Emp_Name like '" + textBox1.Text + "%' ORDER BY Emp_Name ASC";
using (SqlCommand comand = new SqlCommand(query, con))
{
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = comand;
DataTable ds = new DataTable();
ds.Locale = System.Globalization.CultureInfo.InvariantCulture;
da.Fill(ds);
dataGridView1.DataSource = ds;
}
} 
于 2013-04-11T15:49:52.700 回答