1

I have hosted my custom combobox (ComboBoxEx) on datagridview by following the steps in http://msdn.microsoft.com/en-us/library/7tas5c80.aspx.

  1. I have created DataGridVIewComboExColumn derrived from DataGridViewColumn.
  2. Custom cell named "DataGridVIewComboExCell" is created from DataGridViewCell.
  3. Finally my custom edit control "ComboExEditCtrl" (derived from ComboBoxEx and implements IDataGridViewEditingControl) is created.

In ComboExEditCtrl, OnSelectedValueChanged method is overrided as below.

protected override void OnSelectedValueChanged(EventArgs eventargs)
{
valueChanged = true;
this.EditingControlDataGridView.NotifyCurrentCellDirty(true);
base.OnSelectedValueChanged(eventargs);
}

Whenever the grid is loaded, custom control (ComboExEditCtrl) displayed on the cell. The problem is when I change the value on custom control (ComboExEditCtrl) and click on the next cell the custom control disappears. Also when i click back on the same cell (custom control cell) in the datagridview the custom control appears.

I have followed almost the same steps described in MSDN (above link). I dont know what I am missing. Please help

Kaizen
  • 219
  • 2
  • 17
  • 1
    did you follow that example exactly as the example on the MSDN link that you have provided..? it's hard to tell what you have or have not done when you are only showing 1 Method from that link – MethodMan Feb 05 '13 at 16:01
  • You need to Show more code and perhaps a screen shot. – Derek Feb 05 '13 at 16:15

1 Answers1

0

When you create a custom column/cell with your own control in it, the datagridview does not know how to draw your control when in display mode. When you click a cell, the cell goes into edit mode, and whatever control is set as EditType will be used and shown (and is available as DatagridView.EditingControl). In display mode, you will have to override the DataGridViewCell.Paint method to draw the cell as you want it to look.