Click here to Skip to main content
16,020,677 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
hi every body i work with gridview there is acombox in the gridview which autocomplete it works fine but after choose the value and leave to the next colum the value get clear this my code



C#
public AutoCompleteStringCollection AutoCompleteLoad()
        {
           
       
            AutoCompleteStringCollection str = new AutoCompleteStringCollection();

            foreach (DataRow row in dt.Rows)
            {
                str.Add(Convert.ToString(row[1]));
            }
            return str;
        }

        private void Alaa_Load(object sender, EventArgs e)
        {
            this.dataGridView1.CellValidated += new DataGridViewCellEventHandler(dataGridView1_CellValidated);

            dataGridView1.RowPostPaint += dataGridView1_RowPostPaint;

        }

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{


string titleText = dataGridView1.Columns[2].HeaderText;
if (titleText.Equals("proname"))
{
ComboBox cbo = e.Control as ComboBox;
if (cbo != null)
{
cbo.DropDownStyle = ComboBoxStyle.DropDown;
cbo.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
cbo.AutoCompleteCustomSource = AutoCompleteLoad();
cbo.AutoCompleteSource = AutoCompleteSource.CustomSource;
}
}


}


where is the problem and why does it happen? can i find help
Posted
Comments
BillWoodruff 16-May-15 23:05pm    
Are you saying the ComboBox behaves differently inside the Grid than on a Form, or in a Panel ?
ost3z 17-May-15 2:53am    
Inside the gridview when i leave the combox column the value gets clear

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