Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
{private void dataGridViewX1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{

if (e.Control is DataGridViewComboBoxEditingControl)
{
AutoCompleteStringCollection strng = new AutoCompleteStringCollection();
SqlDataReader reader;
con.Open();
SqlCommand cmd = new SqlCommand("select * from Item_tbl ", con);
cmd.CommandType = CommandType.Text;
reader = cmd.ExecuteReader();
if (reader.HasRows == true)
{
while (reader.Read())
{
strng.Add(reader["Name"].ToString());
((ComboBox)e.Control).DropDownStyle = ComboBoxStyle.DropDown;
((ComboBox)e.Control).AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
((ComboBox)e.Control).AutoCompleteSource = AutoCompleteSource.CustomSource;
((ComboBox)e.Control).AutoCompleteCustomSource = strng;

}
}

}
con.Close();
}
}
Posted
Comments
DamithSL 20-Apr-14 23:45pm    
"but as I select a value and... " then what append?
ZurdoDev 21-Apr-14 7:17am    
What?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900