Hi,
public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
ComboBoxControl ctl = DataGridView.EditingControl as ComboBoxControl;
//comment out this line
//ctl.DropDownStyle = ComboBoxStyle.DropDownList;
if (ctl != null)
{
ctl.SelectedIndex = 0;
}
}
If you want to change the style, you can set it in combboxcontrol constructor.
public ComboBoxControl()
: base()
{
this.DropDownStyle = ComboBoxStyle.DropDownList;
this.SelectedIndexChanged += new EventHandler(ComboBoxControl_SelectedIndexChanged);
}
DataGridViewCell.InitializeEditingControl Method
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcell.initializeeditingcontrol.aspx
Best regards,
Ling Wang
Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.