Pages

Sunday, September 20, 2009

DataGridView ComboBox Single click DropDown By Praveen P.R

// C#//It is also possible to drop down the comboboxlist using the DataGridViewComboBoxEditingControl when catching a mouse event:


 private void dgvCompanyList_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
  {
  if(dgvCompanyList[e.ColumnIndex, e.RowIndex].EditType.ToString() == "System.Windows.Forms.DataGridViewComboBoxEditingControl")
  {
  DataGridViewColumn column = dgvCompanyList.Columns[e.ColumnIndex];
  if (column is DataGridViewComboBoxColumn)
  {
  DataGridViewComboBoxCell cell = (DataGridViewComboBoxCell)dgvCompanyList[e.ColumnIndex, e.RowIndex];
  dgvCompanyList.CurrentCell = cell;
  dgvCompanyList.BeginEdit(true);
  DataGridViewComboBoxEditingControl editingControl = (DataGridViewComboBoxEditingControl)dgvCompanyList.EditingControl;
  editingControl.DroppedDown = true;
  }
  }
  }
http://www.prpraveen.blogspot.com

No comments: