the DataGridViewComboBoxCell (dgvcbc) has inconsistent behavior depending on where it is clicked to enter.
- Click the DataGridViewComboBoxCell once to gain focus.
- Click the Arrow portion of the combobox.
- Without using the mouse or arrow keys, type something.
- Press enter.
.
void Main()
{
Application.Run(new Form1());
}
public partial class Form1 : Form
{
public Form1()
{
var gv = new DataGridView();
gv.Columns.Add("col1","col1");
gv.Rows.Add();
var cb = new DataGridViewComboBoxCell();
cb.Items.AddRange(new string[] {"item 1","item 2"});
gv.Rows[0].Cells[0] = cb;
gv.EditingControlShowing += (sender, args) =>
{
var cbCell = args.Control as DataGridViewComboBoxEditingControl;
cbCell.DropDownStyle = ComboBoxStyle.DropDown;
};
gv.CellValidating += (sender, args) =>
{
Console.WriteLine(args.FormattedValue);
};
Controls.Add(gv);
}
}
The typed value doesn't get printed.
I think this is a bug in the DataGridViewComboBoxCell but I wanted confirmation before submitting an actual UPDATE bug report/UPDATE to MS. Also, any ideas for work arounds?