tags:

views:

16

answers:

0

the DataGridViewComboBoxCell (dgvcbc) has inconsistent behavior depending on where it is clicked to enter.

  1. Click the DataGridViewComboBoxCell once to gain focus.
  2. Click the Arrow portion of the combobox.
  3. Without using the mouse or arrow keys, type something.
  4. 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?