wxGrid::GetSelectedRows

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Pat Verner
Earned a small fee
Earned a small fee
Posts: 16
Joined: Mon Sep 06, 2010 6:58 am

wxGrid::GetSelectedRows

Post by Pat Verner »

Hi there

I must be doing something wrong, but I cannot get the wxGrid::GetSelectedRows() to return more than a single row.

The environment is Linux, GCC V4.1.2, wxWidgets 2.8.10:
----------------------
void partnersEd::WxGrid1SelectCell(wxGridEvent& event)
{
int thisrow=event.GetRow();
WxGrid1->SelectRow(thisrow,true); //this should add the indicated row to the list of selected rows...
}
------
void partnersEd::partnersDelete(wxCommandEvent& event)
{
int n;
const wxArrayInt sels(WxGrid1->GetSelectedRows()); // This should return all the selected rows...
int count=sels.size();
if (count > 0 ) {
for (n=0; n<count; n++) {
wxString rownum=WxGrid1->GetCellValue(sels[n],0);
wxFprintf(stderr,"Entries are %d : %s\n", sels[n], rownum.c_str());
}
}
}
In practice, count is always 1, and only the first selected row is returned :-(

Any suggestions would be welcome. At a push I could build up a list of the select rows with an array, etc., but as I understand the issue this should work.
------
Regards
=Pat
okurtsev
Experienced Solver
Experienced Solver
Posts: 54
Joined: Mon Jan 25, 2010 3:26 pm
Location: Ukraine, Kiev

Re: wxGrid::GetSelectedRows

Post by okurtsev »

Probably there is some bug. I also had strange problem or misunderstanding with wxGrid. The mode was whole row selection, not separated cells. And if I selected rows with the ribbon, the number of selected rows was always zero. If rows were selected with ribbon on the row header then everything was okay. To make it less confusing I've turned off the whole row selection and given up.
C++, Win XP-32, Win7-64, WinVista-32, MS VS 2005, 2008, 2010
Post Reply