Automatically expand a combobox when you click a combobox cell in a datagridview

Oi, that was a long title! Rhymes well with the DataGridView control, though - there are it's a BIG control and has a LOT of associated types. To the point, though:

private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
{
  var editType = dataGridView.CurrentCell.EditType;
  if (editType == typeof(DataGridViewComboBoxEditingControl))
  {
    dataGridView.BeginEdit(false);
    if (dataGridView.EditingControl is DataGridViewComboBoxEditingControl)
    {
      var editingControl = dataGridView.EditingControl as DataGridViewComboBoxEditingControl;
      editingControl.DroppedDown = true;
    }
  }
}

Hope this helps,

// S

Comments

Popular posts from this blog

Auto Mapper and Record Types - will they blend?

Unit testing your Azure functions - part 2: Queues and Blobs

Testing WCF services with user credentials and binary endpoints