在自动完成过滤器中,我们需要第二个单词搜索。通过使用我们的代码,我们在c#中只有第一个单词搜索。
private void datagrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e) { if (dgvdetails.CurrentCell.ColumnIndex == 2) {string titleText = dgvdetails.Columns[2].HeaderText; if (titleText.Equals("Product Name"))
{TextBox autoText = e.Control as TextBox; if (autoText != null){autoText.AutoCompleteCustomSource = LoadAutoComplete(); autoText.AutoCompleteMode = AutoCompleteMode.Suggest; autoText.AutoCompleteSource = AutoCompleteSource.CustomSource;}}}}
private AutoCompleteStringCollection LoadAutoComplete(){ DataTable dt = new DataTable(); dt = estimatesub.Searchproduct(num); AutoCompleteStringCollection stringCol = new AutoCompleteStringCollection();
foreach (DataRow row in dt.Rows){ stringCol.Add(Convert.ToString(row[1])); } return stringCol; }