title: How do I handle the wxEVT_GRID_COL_SORT event to sort a grid?
body: <p>I'm trying to sort a wxGrid. Now, <a href="http://docs.wxwidgets.org/trunk/classwx_grid.html" rel="nofollow">the documentation</a> tells me it doesn't support sorting, but that it does generate an event. This documentation tells me the event is called <code>wxEVT_GRID_COL_SORT</code>. Fair enough!</p>
  
  <p>Now, the problem is that I simply don't know how to get the event to work. I have an event table for my frame, which looks something like this:</p>
  
  <pre><code>BEGIN_EVENT_TABLE(MainWindow, wxFrame)
  EVT_BUTTON(XRCID("toevoegknop"), MainWindow::openAddWindow)
  // A few other events that work
  END_EVENT_TABLE()
  </code></pre>
  
  <p>The events listed there already work perfectly fine. In my MainWindow class I declared a function:</p>
  
  <pre><code>void sortColumn(wxGridEvent&amp; event);
  </code></pre>
  
  <p>Now, I want to add said <code>wxEVT_GRID_COL_SORT</code> event. From my point of view the documentation isn't really super clear on what I should do, so I just tried adding the event by adding the following line to the event table.</p>
  
  <pre><code>wxEVT_GRID_COL_SORT(MainWindow::sortColumn)
  </code></pre>
  
  <p>Brings up a syntax error, thus it isn't right. I noticed the other events just started with EVT, so I tried to remove the wx, but I'm still out of luck. </p>
  
  <p>Searching the internet far and wide brought me to a <a href="http://pastebin.com/mJz8gvzE" rel="nofollow">pastebin post</a> which handles the event by adding the following line to the constructor of the frame (in my case MainWindow)</p>
  
  <pre><code>Grid-&gt;Connect(wxEVT_GRID_COL_SORT,(wxObjectEventFunction)&amp;Frame::OnGridColSort);
  </code></pre>
  
  <p>Which I adapted like this (the almost entire constructor for MainWindow)</p>
  
  <pre><code>MainWindow::MainWindow(const wxString&amp; title, const wxPoint&amp; pos, const wxSize&amp; size, Collection* library, MovieDB* database)
  : wxFrame(), library_(library), database_(database) {
  wxXmlResource::Get()-&gt;LoadFrame(this, NULL, _T("hoofdvenster"));
  
  SetSize(size);
  grid_ = (wxGrid *)FindWindowById(XRCID("filmtabel"));
  // Irrelevant code removed, setting up the grid labels etc.
  
  grid_-&gt;Connect(wxEVT_GRID_COL_SORT,(wxObjectEventFunction)&amp;MainWindow::sortColumn);
  }
  </code></pre>
  
  <p>Which throws up an error:</p>
  
  <blockquote>
    <p>‘wxEVT_GRID_COL_SORT’ was not declared in this scope</p>
  </blockquote>
  
  <p>So now I don't know what else I can try. Please do keep in mind that I only started messing about with wxWidgets a few days ago, so things that are trivial to any wxWidgets user might not be for me.</p>
  
  <p>Thanks in advance!</p>