Using Shift + click to select Cells in wxGrid will not count

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
knightmare0
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

Using Shift + click to select Cells in wxGrid will not count

Post by knightmare0 »

Here is what I did, I basically tried to make a copy-paste function for my timetable using a wxGrid, sounds dead easy right? but I found out that when I used ->GetSelectedCells(), it will only count the cells selected using the Ctrl + click method, when the Shift + click method is used it did not count the cells in the array. the following are the codes I used:

TimeTable is my wxGrid

Code: Select all


//showing the total number of cells selected
 TimeTable->SetCellValue(0,1,"Cell Selected Total: "+IntStr(TimeTable->GetSelectedCells().GetCount()));

//value of first selection
    TimeTable->SetCellValue(1,1,"Cell 1 value: "+TimeTable->GetCellValue(
                                                    TimeTable->GetSelectedCells().Item(0)));

//coords of first selection
    TimeTable->SetCellValue(2,1,"Cell 1 row: "+ IntStr(                                                                         (TimeTable->GetSelectedCells().Item(0)).GetRow()) );

    TimeTable->SetCellValue(3,1,"Cell 1 col: "+ IntStr(  (TimeTable->GetSelectedCells().Item(0)).GetCol()) );


the outcomes are strange, if I use the ctrl + click method everything works fine, but when I use the shift + click method the TimeTable->GetSelectedCells().GetCount() shows up as 0.

Is this a bug? or M I missing something?

anyone know how to fix this?

TIA
cheers!
bloodlee
Experienced Solver
Experienced Solver
Posts: 77
Joined: Thu Nov 30, 2006 10:49 am
Location: Shenzhen, CHN

Post by bloodlee »

Hi.
Please try to use wxGrid::IsInSelection to check whether the cell is selected. So you need go through all cells.

It seems a bug of wx, at least in wx 2.6.2. :)
knightmare0
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

Post by knightmare0 »

oh lord, I have to check every cell? but I have a lot of cells...

I tried writing code to keep track of selected cells by monitoring keys pressed, but its really messy.

any other way?
knightmare0
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sat Mar 29, 2008 9:18 pm

Post by knightmare0 »

can anyone confirm this is a bug? or is there something wrong with my wxWidget?
Post Reply