wxGrid GetSelectedCells 返回空数组

wxGrid GetSelectedCells returns empty array

本文关键字:数组 返回 GetSelectedCells wxGrid      更新时间:2023-10-16

我想在使用单击按钮时删除选定的行。

到目前为止,代码如下所示:

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();

问题是无论我选择什么,wx_cells变量总是空的。我尝试使用GetSelectedRows没有成功。我已经添加了SetFocusSetSelectionMode希望它会有所帮助,但它没有。

我怎样才能让它工作?

您使用的是哪个版本的 wxgrid?旧的wxgrid似乎有一个问题,它在调用GetSelectedCells时总是返回空。也许您可以参考 http://forums.wxwidgets.org/viewtopic.php?t=6335 来尝试它是否适合您的情况。