in wxwidgets c++ project, how to pin rows in wxgrid? I know it can be done with freezeto…
- User
in wxwidgets c++ project, how to pin rows in wxgrid? I know it can be done with freezeto but I want to be able to pin any number of rows in any position, for example, pinning the first and the third but not the second.
- Assistant
- User
I want to be able to set this pinnedrow values from outside, for example in my frame, and I want this method to receive the value and if it doesn't exist then it add it to the pinnedrow and if it does then remove it from the pinned rows
- Assistant
To set the pinned row values from outside, you can create a custom function in the
CustomGridclass that receives the row index and toggles the pin state accordingly. Here's an example:class CustomGrid : public wxGrid { public: // ... void SetPinnedRow(int row, bool pinned) { if (pinned) pinnedRows.insert(row); else pinnedRows.erase(row); Refresh(); // Redraw the grid with updated pinning } // ... };Then, in your frame class or wherever you want to set the pinned rows, you can call this function to add or remove rows from the pinned rows:
void MyFrame::SetRowPinning(int row, bool pinned) { CustomGrid* grid = GetGrid(); // Assuming you have a function to retrieve the grid object grid->SetPinnedRow(row, pinned); }This way, you can set the pinning state of any row from anywhere in your code by calling the
SetRowPinningfunction, passing the row index and the desired pinning state. If the row doesn't exist in the pinned rows, it will be added, and if it already exists, it will be removed.You can also extend the
SetRowPinningfunction to handle multiple rows at once if needed by accepting a range or a vector of row indexes. - User
Ok I want to do it from start, guide me how to do it from the creating of CustomGrid.h to implementation in CustomGrid.cpp
- Assistant
- User
it is giving me these errors:
include/CustomGrid.h:15:14: error: ‘void CustomGrid::DrawRowLabel(wxDC&, int*, int)’ marked ‘override’, but does not override
include/CustomGrid.h:16:14: error: ‘void CustomGrid::DrawCell(wxGridCellRenderer*, int, int, wxDC&, const wxRect&, int)’ marked ‘override’, but does not override
- Assistant