Click here to Skip to main content
15,889,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
here is my code

C#
private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  {
    if (e.Control.GetType() == typeof(DataGridViewComboBoxEditingControl))
    {
      DataGridViewComboBoxEditingControl combo = e.Control as DataGridViewComboBoxEditingControl;
      combo.DropDownStyle = ComboBoxStyle.DropDown;
      combo.TextChanged += new EventHandler(combo_TextChanged);
    }
  }


i want to change my DataGridViewComboBoxCell style to dropdown..(to change the combobox DropDownStyle to allow for the user to enter text while the combobox is in edit mode)
but unfortunately, the standard DataGridView does not allow this to happen at Design-Time so i want to pull some tricks. When the field loses focus and the edit control is no longer available, the combobox reverts its style. Therefore, the validating event is being used to add values into the list of available values so that the items can still be displayed correctly.

pls help me,

-tushar
Posted
Updated 29-Oct-14 21:33pm
v2
Comments
George Jonsson 30-Oct-14 4:22am    
Are the items in the combobox bound to a data source or do you add them manually?
Herman<T>.Instance 30-Oct-14 6:48am    
Can you set AutoPostBack=true to combo?

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