2013-10-18 86 views
1

我想在使用單擊按鈕時刪除選定的行。wxGrid GetSelectedCells返回空數組

到目前爲止的代碼看起來像這樣:

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希望它會幫助,但它沒有。

我該如何得到這個工作?

回答

1

您使用的是什麼版本的wxgrid?舊的wxgrid似乎存在一個問題,即在調用GetSelectedCells時它總是返回空。也許你可以參考http://forums.wxwidgets.org/viewtopic.php?t=6335來試試它是否適合你的情況。

+0

到目前爲止,我對該論壇帖子的總結:'wxGridSelectCells'模式不起作用。 'GetSelectedRows','GetSelectedCols','GetSelectedCells'不起作用。解決方案是使用塊:'GetSelectionBlockTopLeft'和'GetSelectionBlockBottomRight'。如果你想做一些簡單的事情,你也可以通過網格單元並調用IsInSelection – Arthur