I am having DataGridView
in a winforms application with a number of ComboBox
control. I converted the ComboBox
to make it editable.
However, since then, the changes in the column are not being updated in the underlying class object.
When I debug the code, I noticed that the CellValuePushed()
event handler was not called when the changes are made in the ComboBox
cell.
Any idea what I am missing ?
Thanks
I noticed, when I enter the value in the ComboBox
, the CellValueNeeded()
eventhandler is being called.
Notice in the screenshot, when I try to enter the data in the combox cell, CellValueNeeded()
eventhandler is called
Update :
private void UserDataTable_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if ((UserDataTable.CurrentCell.ColumnIndex == 4) ||
(UserDataTable.CurrentCell.ColumnIndex == 6) ||
(UserDataTable.CurrentCell.ColumnIndex == 8) ||
(UserDataTable.CurrentCell.ColumnIndex == 11))
{
ComboBox combo = e.Control as ComboBox;
combo.DropDownStyle = ComboBoxStyle.DropDown;
if (combo == null)
return;
}
}
private void UserDataTable_CellValuePushed(object sender, DataGridViewCellValueEventArgs e)
{
IntVector temp1 = this.UserData[e.RowIndex];
switch (e.ColumnIndex)
{
case 0: temp1.DeleteMember = (bool)e.Value;
break;
case 1:
temp1.Date1 = Convert.ToDateTime(e.Value).ToString("dd-MM-yy");
break;
case 2:
temp1.CaseNo = Convert.ToString(e.Value);
break;
case 3:
break;
}
}