void DrawGridCellArea( wxDC& dc );
     void DrawCellBorder( wxDC& dc, const wxGridCellCoords& );
-    void DrawAllGridLines( wxDC& dc, const wxRegion & reg = wxRegion() );
+    void DrawAllGridLines( wxDC& dc, const wxRegion & reg );
     void DrawCell( wxDC& dc, const wxGridCellCoords& );
     void DrawCellBackground( wxDC& dc, const wxGridCellCoords& );
     void DrawCellValue( wxDC& dc, const wxGridCellCoords& );
 
 protected:
     bool m_created;
+    bool m_displayed;
 
     wxGridWindow             *m_gridWin;
     wxGridRowLabelWindow     *m_rowLabelWin;
 
 
 void wxGrid::Create()
 {
+    m_created = FALSE;    // set to TRUE by CreateGrid
+    m_displayed = FALSE;  // set to TRUE by OnPaint
+
+    m_table        = (wxGridTableBase *) NULL;
+    m_cellEditCtrl = (wxWindow *) NULL;
+
+    m_numRows = 0;
+    m_numCols = 0;
+    m_currentCellCoords = wxGridNoCellCoords;
+    
     int colLblH = WXGRID_DEFAULT_COL_LABEL_HEIGHT;
     int rowLblW = WXGRID_DEFAULT_ROW_LABEL_WIDTH;
 
 
 void wxGrid::CalcDimensions()
 {
+    // This avoids a crash in SetScrollbars
+    //
+    if ( !m_displayed ) return;
+    
     int cw, ch;
     GetClientSize( &cw, &ch );
 
         SetEditControlValue();
         ShowCellEditControl();
     }
+
+    m_displayed = TRUE;
 }
 
 
         return;
     }
 
-    wxClientDC dc( m_gridWin );
-    PrepareDC( dc );
-
-    if ( m_currentCellCoords != wxGridNoCellCoords )
+    if ( m_displayed  &&
+         m_currentCellCoords != wxGridNoCellCoords )
     {
         HideCellEditControl();
         SaveEditControlValue();
     m_currentCellCoords = coords;
 
     SetEditControlValue();
-    ShowCellEditControl();
 
-    if ( IsSelection() )
+    if ( m_displayed )
     {
-        wxRect r( SelectionToDeviceRect() );
-        ClearSelection();
-        if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
+        ShowCellEditControl();
+
+        if ( IsSelection() )
+        {
+            wxRect r( SelectionToDeviceRect() );
+            ClearSelection();
+            if ( !GetBatchCount() ) m_gridWin->Refresh( FALSE, &r );
+        }
     }
 }