title: Refreshing wxGrid with dynamic contents
body: <p>This doesn't seem to be as simple as I'd hoped:</p>
  
  <p>Using wxWidgets (2.8 stable series), I have a wxGrid (not subclassed) with a custom “data adapter” as a wxGridTableBase-derived class.</p>
  
  <pre><code>wxGrid* grid = new wxGrid (this, ID_TABLE);
  grid-&gt;SetTable (new TableAdapter (foo, bar, baz));
  grid-&gt;EnableEditing (false);
  sizer-&gt;Add(grid, wxSizerFlags (1).Expand());
  </code></pre>
  
  <p>The “simple” thing that I can't find is a way to refresh the grid when the underlying data model changes. Simply calling wxWindow::Update (<code>pGrid-&gt;Update()</code>) is apparently insufficient to actually get the grid to call the underlying wxGridTableBase implementation?</p>
  
  <pre><code>wxGrid* const grid = (wxGrid* const) FindWindow (ID_TABLE);
  if (NULL != grid) {
       grid-&gt;Update ();
       grid-&gt;AutoSizeColumns ();
  }
  </code></pre>
  
  <p>In particular, this grid is acting as a list, and will have rows added and removed from it asynchronously, by either the same or (potentially) another process — it's a shared data list that can be updated by any one of several networked systems. The grid/list itself is effectively read-only; other controls are used to add and remove items, and each row has one boolean-type attribute that can be toggled as well.</p>
  
  <p>It seems that new rows aren't added to the view, and deleting rows will cause intermittent SEGV's in the wx drawing code.</p>
  
  <p>Due to the dynamic/asynchronous updating mechanism, I'm <em>hoping</em> to avoid having to delete and re-add the grid to the window constantly, as I'm sure that will cause all sorts of flicker and nastiness… so, I'll fall back on trying something brute-force like that, if I absolutely must, but I'd strongly prefer to avoid it.</p>
  
  <p>Unfortunately, despite being flagged as the “stable version,” the wxGrid documentation appears to mostly consist of <code>Yet to be written</code> tags.</p>
  
  <p><strong>Updated:</strong>
  I'm becoming suspicious that this is a layout-of-container problem. In drawing the grid, the bottom of the grid (last row) can actually overlap both the wxStaticBox frame around its section of the wxFrame window, as well as part of the status line of the frame. Adding and removing rows doesn't seem to force a re-layout of the container; I'm experimenting with trying to call <code>Layout</code> and the like. Ideally, this should be a scrolling region, but the wxGrid <em>should</em> still be “constrained” within its containing Sizer. </p>
  
  <p>The layout consists, effectively, of a static box, containing a vertical box, the first element of which is a horizontal box of buttons, then the grid, as so:</p>
  
  <pre><code>    --[ Static Box ]------------------------
     |                                        |
     | [Button] [Button] [Button]             |
     |                                        |
     |  -----------------------------------   |
     | |      |   A      |   B   |    C    |  |
     | |-----------------------------------|  |
     | |    1 |   1a     |   1b  |    1c   |  |
     |  -----------------------------------   |
     |                                        |
      ----------------------------------------
  </code></pre>
  
  <p>Unfortunately, company policy prohibits me from posting screenshots :-(</p>
  
  <p>If it matters, this is (presently) wxGTK-2.8.12 on Fedora 16 (x86_64), although I'm seeing identical behaviour on CentOS5/RHEL5 using the EPEL (Fedora) packages.</p>