diff --git a/include/wx/generic/grid.h b/include/wx/generic/grid.h index 95f688ed6c..d349fd9d78 100644 --- a/include/wx/generic/grid.h +++ b/include/wx/generic/grid.h @@ -1068,6 +1068,7 @@ public: void DisableCellEditControl() { EnableCellEditControl(FALSE); } bool CanEnableCellControl() const; bool IsCellEditControlEnabled() const; + bool IsCellEditControlDisplayed() const; bool IsCurrentCellReadOnly() const; diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 6f9b958a4f..fa2ba8e649 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -5945,6 +5945,23 @@ bool wxGrid::IsCellEditControlEnabled() const return m_cellEditCtrlEnabled ? !IsCurrentCellReadOnly() : FALSE; } +bool wxGrid::IsCellEditControlDisplayed() const +{ + if (m_cellEditCtrlEnabled) + { + int row = m_currentCellCoords.GetRow(); + int col = m_currentCellCoords.GetCol(); + wxGridCellAttr* attr = GetCellAttr(row, col); + wxGridCellEditor* editor = attr->GetEditor(this, row, col); + if ( editor && editor->IsCreated() ) + { + wxWindow *control = editor->GetControl(); + return control->IsShown(); + } + } + return FALSE; +} + void wxGrid::ShowCellEditControl() { if ( IsCellEditControlEnabled() ) @@ -7693,7 +7710,10 @@ void wxGrid::SetCellValue( int row, int col, const wxString& s ) if ( m_currentCellCoords.GetRow() == row && m_currentCellCoords.GetCol() == col && - IsCellEditControlEnabled()) + IsCellEditControlDisplayed()) + // Note: If we are using IsCellEditControlEnabled, + // this interacts badly with calling SetCellValue from + // an EVT_GRID_CELL_CHANGE handler. { HideCellEditControl(); ShowCellEditControl(); // will reread data from table