- // we need to preserve the old position ourselves as the column doesn't
- // store it (TODO: should it?)
- const unsigned int pos = GetColumnPos(idx);
- Header_DeleteItem(GetHwnd(), idx);
- DoInsertItem(idx, pos);
+ const wxHeaderColumn& col = GetColumn(idx);
+ if ( col.IsHidden() )
+ {
+ // column is hidden now
+ if ( !m_isHidden[idx] )
+ {
+ // but it wasn't hidden before, so remove it
+ Header_DeleteItem(GetHwnd(), MSWToNativeIdx(idx));
+
+ m_isHidden[idx] = true;
+ }
+ //else: nothing to do, updating hidden column doesn't have any effect
+ }
+ else // column is shown now
+ {
+ if ( m_isHidden[idx] )
+ {
+ m_isHidden[idx] = false;
+ }
+ else // and it was shown before as well
+ {
+ // we need to remove the old column
+ Header_DeleteItem(GetHwnd(), MSWToNativeIdx(idx));
+ }
+
+ DoInsertItem(col, idx);
+ }