// set the number of columns in the control
     //
     // this also calls UpdateColumn() for all columns
-    void SetColumnCount(unsigned int count) { DoSetCount(count); }
+    void SetColumnCount(unsigned int count);
 
     // return the number of columns in the control as set by SetColumnCount()
     unsigned int GetColumnCount() const { return DoGetCount(); }
         return false;
     }
 
+    // this method can be overridden in the derived classes to do something
+    // (e.g. update/resize some internal data structures) before the number of
+    // columns in the control changes
+    virtual void OnColumnCountChanging(unsigned int WXUNUSED(count)) { }
+
 private:
     // methods implementing our public API and defined in platform-specific
     // implementations
 
             meaning that the control didn't reach to the separator double click.
      */
     virtual bool UpdateColumnWidthToFit(unsigned int idx, int widthTitle);
+
+    /**
+        Can be overridden in the derived class to update internal data
+        structures when the number of the columns in the control changes.
+
+        This method is called by SetColumnCount() before effectively changing
+        the number of columns.
+
+        The base class version does nothing but it is good practice to still
+        call it from the overridden version in the derived class.
+     */
+    virtual void OnColumnCountChanging(unsigned int count);
 };
 
 
 
     DoScrollHorz(dx);
 }
 
+void wxHeaderCtrlBase::SetColumnCount(unsigned int count)
+{
+    OnColumnCountChanging(count);
+
+    DoSetCount(count);
+}
+
 // ----------------------------------------------------------------------------
 // wxHeaderCtrlBase event handling
 // ----------------------------------------------------------------------------