diff --git a/src/generic/datavgen.cpp b/src/generic/datavgen.cpp index bca358a7e0..22627a3ea2 100644 --- a/src/generic/datavgen.cpp +++ b/src/generic/datavgen.cpp @@ -5070,8 +5070,35 @@ void wxDataViewMainWindow::UpdateColumnSizes() int fullWinWidth = GetSize().x; - wxDataViewColumn *lastCol = owner->GetColumn(colsCount - 1); - int colswidth = GetEndOfLastCol(); + // Find the last shown column: we shouldn't bother to resize the columns + // that are hidden anyhow. + int lastColIndex = -1; + wxDataViewColumn *lastCol wxDUMMY_INITIALIZE(NULL); + for ( int colIndex = colsCount - 1; colIndex >= 0; --colIndex ) + { + lastCol = owner->GetColumnAt(colIndex); + if ( !lastCol->IsHidden() ) + { + lastColIndex = colIndex; + break; + } + } + + if ( lastColIndex == -1 ) + { + // All columns are hidden. + return; + } + + int colswidth = 0; + for ( int colIndex = 0; colIndex < lastColIndex; ++colIndex ) + { + const wxDataViewColumn *c = owner->GetColumnAt(colIndex); + + if ( !c->IsHidden() ) + colswidth += c->GetWidth(); + } + int lastColX = colswidth - lastCol->GetWidth(); if ( lastColX < fullWinWidth ) {