diff --git a/src/generic/grid.cpp b/src/generic/grid.cpp index 17cae6e47e..45c34892dd 100644 --- a/src/generic/grid.cpp +++ b/src/generic/grid.cpp @@ -2347,12 +2347,15 @@ wxGrid::SetTable(wxGridTableBase *table, m_numRows = table->GetNumberRows(); m_numCols = table->GetNumberCols(); - if ( m_useNativeHeader ) - GetGridColHeader()->SetColumnCount(m_numCols); - m_table = table; m_table->SetView( this ); m_ownTable = takeOwnership; + + // Notice that this must be called after setting m_table as it uses it + // indirectly, via wxGrid::GetColLabelValue(). + if ( m_useNativeHeader ) + GetGridColHeader()->SetColumnCount(m_numCols); + m_selection = new wxGridSelection( this, selmode ); if (checkSelection) {