0

I am having DataGridView in a 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

enter image description here

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;
    }
}
Abhishek
  • 2,925
  • 4
  • 34
  • 59
Kiran
  • 8,034
  • 36
  • 110
  • 176
  • 1
    Could you explain what you're trying to accomplish with the Combobox and Datagridview? Is the combo box nested on top of the Datagridview? Are you trying to have a Datagridview with cells that are set via dropdown? A full sc of your grid would help, too. – JWiley Dec 07 '12 at 15:42
  • I was able to fix the issue using the combobox selectindexchanged event handler. I would populate the datagridview with the new value when the value is changed – Kiran Dec 10 '12 at 10:32

0 Answers0