Search code examples
c++windowswxwidgets

wxGrid GetSelectedCells returns empty array


I want to delete selected rows when the use click on a button.

so far the code looks like that:

this->grid_ = new wxGrid(parent, ...)
this->grid_->SetSelectionMode(wxGrid::wxGridSelectCells);
// Later, whene the button is clicked
this->grid_->SetFocus();
wxGridCellCoordsArray wx_cells = this->grid_->GetSelectedCells();

The problem is that the wx_cells variable is always empty whatever I select. I tried with GetSelectedRows with no success. I've added SetFocus and SetSelectionMode hoping it would help but it did not.

How can I get this to work ?


Solution

  • What version of wxgrid are you using? There seems to be an issue with old wxgrid that it always return empty when calling GetSelectedCells. Perhaps you can refer to http://forums.wxwidgets.org/viewtopic.php?t=6335 to try if it fits in your case.