wxGridwxGrid and its related classes are used for displaying and editing tabular data. They provide a rich set of features for display, editing, and interacting with a variety of data sources. For simple applications, and to help you get started, wxGrid is the only class you need to refer to directly. It will set up default instances of the other classes and manage them for you. For more complex applications you can derive your own classes for custom grid views, grid data tables, cell editors and renderers. The wxGrid classes overview has examples of simple and more complex applications, explains the relationship between the various grid classes and has a summary of the keyboard shortcuts and mouse functions provided by wxGrid. wxGrid has been greatly expanded and redesigned for wxWidgets 2.2 onwards. If you have been using the old wxGrid class you will probably want to have a look at the wxGrid classes overview to see how things have changed. The new grid classes are reasonably backward-compatible but there are some exceptions. There are also easier ways of doing many things compared to the previous implementation. Derived from
wxScrolledWindow Include files <wx/grid.h> Window styles There are presently no specific window styles for wxGrid. Event handling The event handler for the following functions takes a wxGridEvent parameter. The ..._CMD_... variants also take a window identifier.
Function groups
Constructors and initialization
Constructors and initialization
wxGrid
Display format
Selection functions
wxGrid::ClearSelection
wxGrid::wxGridwxGrid() Default constructor wxGrid(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxWANTS_CHARS, const wxString& name = wxPanelNameStr) Constructor to create a grid object. Call either wxGrid::CreateGrid or wxGrid::SetTable directly after this to initialize the grid before using it.
wxGrid::~wxGrid~wxGrid() Destructor. This will also destroy the associated grid table unless you passed a table object to the grid and specified that the grid should not take ownership of the table (see wxGrid::SetTable).
wxGrid::AppendColsbool AppendCols(int numCols = 1, bool updateLabels = true) Appends one or more new columns to the right of the grid and returns true if successful. The updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::AppendCols. See wxGrid::InsertCols for further information.
wxGrid::AppendRowsbool AppendRows(int numRows = 1, bool updateLabels = true) Appends one or more new rows to the bottom of the grid and returns true if successful. The updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::AppendRows. See wxGrid::InsertRows for further information.
wxGrid::AutoSizevoid AutoSize() Automatically sets the height and width of all rows and columns to fit their contents.
Note
wxGrid::AutoSizeColumnvoid AutoSizeColumn(int col, bool setAsMin = true) Automatically sizes the column to fit its contents. If setAsMin is true the calculated width will also be set as the minimal width for the column.
Note
wxGrid::AutoSizeColumnsvoid AutoSizeColumns(bool setAsMin = true) Automatically sizes all columns to fit their contents. If setAsMin is true the calculated widths will also be set as the minimal widths for the columns.
Note
wxGrid::AutoSizeRowvoid AutoSizeRow(int row, bool setAsMin = true) Automatically sizes the row to fit its contents. If setAsMin is true the calculated height will also be set as the minimal height for the row.
Note
wxGrid::AutoSizeRowsvoid AutoSizeRows(bool setAsMin = true) Automatically sizes all rows to fit their contents. If setAsMin is true the calculated heights will also be set as the minimal heights for the rows.
Note
wxGrid::BeginBatchvoid BeginBatch() Increments the grid's batch count. When the count is greater than zero repainting of the grid is suppressed. Each call to BeginBatch must be matched by a later call to wxGrid::EndBatch. Code that does a lot of grid modification can be enclosed between BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will cause the grid to be repainted.
wxGrid::BlockToDeviceRectwxRect BlockToDeviceRect(const wxGridCellCoords & topLeft, const wxGridCellCoords & bottomRight) This function returns the rectangle that encloses the block of cells limited by TopLeft and BottomRight cell in device coords and clipped to the client size of the grid window.
wxGrid::CanDragColMovebool CanDragColMove() Returns true if columns can be moved by dragging with the mouse. Columns can be moved by dragging on their labels.
wxGrid::CanDragColSizebool CanDragColSize() Returns true if columns can be resized by dragging with the mouse. Columns can be resized by dragging the edges of their labels. If grid line dragging is enabled they can also be resized by dragging the right edge of the column in the grid cell area (see wxGrid::EnableDragGridSize).
wxGrid::CanDragRowSizebool CanDragRowSize() Returns true if rows can be resized by dragging with the mouse. Rows can be resized by dragging the edges of their labels. If grid line dragging is enabled they can also be resized by dragging the lower edge of the row in the grid cell area (see wxGrid::EnableDragGridSize).
wxGrid::CanDragGridSizebool CanDragGridSize() Return true if the dragging of grid lines to resize rows and columns is enabled or false otherwise.
wxGrid::CanEnableCellControlbool CanEnableCellControl() const Returns true if the in-place edit control for the current grid cell can be used and false otherwise (e.g. if the current cell is read-only).
wxGrid::CanHaveAttributesbool CanHaveAttributes() Do we have some place to store attributes in?
wxGrid::CellToRectwxRect CellToRect(int row, int col) wxRect CellToRect(const wxGridCellCoords& coords) Return the rectangle corresponding to the grid cell's size and position in logical coordinates.
wxGrid::ClearGridvoid ClearGrid() Clears all data in the underlying grid table and repaints the grid. The table is not deleted by this function. If you are using a derived table class then you need to override wxGridTableBase::Clear for this function to have any effect.
wxGrid::ClearSelectionvoid ClearSelection() Deselects all cells that are currently selected.
wxGrid::CreateGridbool CreateGrid(int numRows, int numCols, wxGrid::wxGridSelectionModes selmode = wxGrid::wxGridSelectCells) Creates a grid with the specified initial number of rows and columns. Call this directly after the grid constructor. When you use this function wxGrid will create and manage a simple table of string values for you. All of the grid data will be stored in memory. For applications with more complex data types or relationships, or for dealing with very large datasets, you should derive your own grid table class and pass a table object to the grid with wxGrid::SetTable.
wxGrid::DeleteColsbool DeleteCols(int pos = 0, int numCols = 1, bool updateLabels = true) Deletes one or more columns from a grid starting at the specified position and returns true if successful. The updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::DeleteCols. See wxGrid::InsertCols for further information.
wxGrid::DeleteRowsbool DeleteRows(int pos = 0, int numRows = 1, bool updateLabels = true) Deletes one or more rows from a grid starting at the specified position and returns true if successful. The updateLabels argument is not used at present. If you are using a derived grid table class you will need to override wxGridTableBase::DeleteRows. See wxGrid::InsertRows for further information.
wxGrid::DisableCellEditControlvoid DisableCellEditControl() Disables in-place editing of grid cells. Equivalent to calling EnableCellEditControl(false).
wxGrid::DisableDragColMovevoid DisableDragColMove() Disables column moving by dragging with the mouse. Equivalent to passing false to wxGrid::EnableDragColMove.
wxGrid::DisableDragColSizevoid DisableDragColSize() Disables column sizing by dragging with the mouse. Equivalent to passing false to wxGrid::EnableDragColSize.
wxGrid::DisableDragGridSizevoid DisableDragGridSize() Disable mouse dragging of grid lines to resize rows and columns. Equivalent to passing false to wxGrid::EnableDragGridSize
wxGrid::DisableDragRowSizevoid DisableDragRowSize() Disables row sizing by dragging with the mouse. Equivalent to passing false to wxGrid::EnableDragRowSize.
wxGrid::EnableCellEditControlvoid EnableCellEditControl(bool enable = true) Enables or disables in-place editing of grid cell data. The grid will issue either a wxEVT_GRID_EDITOR_SHOWN or wxEVT_GRID_EDITOR_HIDDEN event.
wxGrid::EnableDragColSizevoid EnableDragColSize(bool enable = true) Enables or disables column sizing by dragging with the mouse.
wxGrid::EnableDragColMovevoid EnableDragColMove(bool enable = true) Enables or disables column moving by dragging with the mouse.
wxGrid::EnableDragGridSizevoid EnableDragGridSize(bool enable = true) Enables or disables row and column resizing by dragging gridlines with the mouse.
wxGrid::EnableDragRowSizevoid EnableDragRowSize(bool enable = true) Enables or disables row sizing by dragging with the mouse.
wxGrid::EnableEditingvoid EnableEditing(bool edit) If the edit argument is false this function sets the whole grid as read-only. If the argument is true the grid is set to the default state where cells may be editable. In the default state you can set single grid cells and whole rows and columns to be editable or read-only via wxGridCellAttribute::SetReadOnly. For single cells you can also use the shortcut function wxGrid::SetReadOnly. For more information about controlling grid cell attributes see the wxGridCellAttr cell attribute class and the wxGrid classes overview.
wxGrid::EnableGridLinesvoid EnableGridLines(bool enable = true) Turns the drawing of grid lines on or off.
wxGrid::EndBatchvoid EndBatch() Decrements the grid's batch count. When the count is greater than zero repainting of the grid is suppressed. Each previous call to wxGrid::BeginBatch must be matched by a later call to EndBatch. Code that does a lot of grid modification can be enclosed between BeginBatch and EndBatch calls to avoid screen flicker. The final EndBatch will cause the grid to be repainted.
wxGrid::Fitvoid Fit() Overridden wxWindow method.
wxGrid::ForceRefreshvoid ForceRefresh() Causes immediate repainting of the grid. Use this instead of the usual wxWindow::Refresh.
wxGrid::GetBatchCountint GetBatchCount() Returns the number of times that wxGrid::BeginBatch has been called without (yet) matching calls to wxGrid::EndBatch. While the grid's batch count is greater than zero the display will not be updated.
wxGrid::GetCellAlignmentvoid GetCellAlignment(int row, int col, int* horiz, int* vert) Sets the arguments to the horizontal and vertical text alignment values for the grid cell at the specified location.
Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. wxPerl note: This method only takes the parameters row and col and returns a 2-element list ( horiz, vert ).
wxGrid::GetCellBackgroundColourwxColour GetCellBackgroundColour(int row, int col) Returns the background colour of the cell at the specified location.
wxGrid::GetCellEditorwxGridCellEditor* GetCellEditor(int row, int col) Returns a pointer to the editor for the cell at the specified location. See wxGridCellEditor and the wxGrid overview for more information about cell editors and renderers.
wxGrid::GetCellFontwxFont GetCellFont(int row, int col) Returns the font for text in the grid cell at the specified location.
wxGrid::GetCellRendererwxGridCellRenderer* GetCellRenderer(int row, int col) Returns a pointer to the renderer for the grid cell at the specified location. See wxGridCellRenderer and the wxGrid overview for more information about cell editors and renderers.
wxGrid::GetCellTextColourwxColour GetCellTextColour(int row, int col) Returns the text colour for the grid cell at the specified location.
wxGrid::GetCellValuewxString GetCellValue(int row, int col) wxString GetCellValue(const wxGridCellCoords&coords) Returns the string contained in the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with wxGrid::SetCellValue to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. See wxGridTableBase::CanGetValueAs and the wxGrid overview for more information.
wxGrid::GetColAtint GetColAt(int colPos) const Returns the column ID of the specified column position.
wxGrid::GetColLeftint GetColLeft(int col) const
wxGrid::GetColLabelAlignmentvoid GetColLabelAlignment(int* horiz, int* vert) Sets the arguments to the current column label alignment values.
Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. wxPerl note: This method takes no parameters and returns a 2-element list ( horiz, vert ).
wxGrid::GetColLabelSizeint GetColLabelSize() Returns the current height of the column labels.
wxGrid::GetColLabelValuewxString GetColLabelValue(int col) Returns the specified column label. The default grid table class provides column labels of the form A,B...Z,AA,AB...ZZ,AAA... If you are using a custom grid table you can override wxGridTableBase::GetColLabelValue to provide your own labels.
wxGrid::GetColMinimalAcceptableWidthint GetColMinimalAcceptableWidth() This returns the value of the lowest column width that can be handled correctly. See member SetColMinimalAcceptableWidth for details.
wxGrid::GetColMinimalWidthint GetColMinimalWidth(int col) const Get the minimal width of the given column/row.
wxGrid::GetColPosint GetColPos(int colID) const Returns the position of the specified column.
wxGrid::GetColRightint GetColRight(int col) const
wxGrid::GetColSizeint GetColSize(int col) Returns the width of the specified column.
wxGrid::GetDefaultCellAlignmentvoid GetDefaultCellAlignment(int* horiz, int* vert) Sets the arguments to the current default horizontal and vertical text alignment values.
Horizontal alignment will be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
wxGrid::GetDefaultCellBackgroundColourwxColour GetDefaultCellBackgroundColour() Returns the current default background colour for grid cells.
wxGrid::GetDefaultCellFontwxFont GetDefaultCellFont() Returns the current default font for grid cell text.
wxGrid::GetDefaultCellTextColourwxColour GetDefaultCellTextColour() Returns the current default colour for grid cell text.
wxGrid::GetDefaultColLabelSizeint GetDefaultColLabelSize() Returns the default height for column labels.
wxGrid::GetDefaultColSizeint GetDefaultColSize() Returns the current default width for grid columns.
wxGrid::GetDefaultEditorwxGridCellEditor* GetDefaultEditor() const Returns a pointer to the current default grid cell editor. See wxGridCellEditor and the wxGrid overview for more information about cell editors and renderers.
wxGrid::GetDefaultEditorForCellwxGridCellEditor* GetDefaultEditorForCell(int row, int col) const wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const
wxGrid::GetDefaultEditorForTypewxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const
wxGrid::GetDefaultRendererwxGridCellRenderer* GetDefaultRenderer() const Returns a pointer to the current default grid cell renderer. See wxGridCellRenderer and the wxGrid overview for more information about cell editors and renderers.
wxGrid::GetDefaultRendererForCellwxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const
wxGrid::GetDefaultRendererForTypewxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const
wxGrid::GetDefaultRowLabelSizeint GetDefaultRowLabelSize() Returns the default width for the row labels.
wxGrid::GetDefaultRowSizeint GetDefaultRowSize() Returns the current default height for grid rows.
wxGrid::GetGridCursorColint GetGridCursorCol() Returns the current grid cell column position.
wxGrid::GetGridCursorRowint GetGridCursorRow() Returns the current grid cell row position.
wxGrid::GetGridLineColourwxColour GetGridLineColour() Returns the colour used for grid lines. See also
wxGrid::GetDefaultGridLinePenwxPen GetDefaultGridLinePen() Returns the pen used for grid lines. This virtual function may be overridden in derived classes in order to change the appearance of grid lines. Note that currently the pen width must be 1. See also
GetColGridLinePen(),
wxGrid::GetRowGridLinePenwxPen GetRowGridLinePen(int row) Returns the pen used for horizontal grid lines. This virtual function may be overridden in derived classes in order to change the appearance of individual grid line for the given row row.
Example: // in a grid displaying music notation, use a solid black pen between // octaves (C0=row 127, C1=row 115 etc.) wxPen MidiGrid::GetRowGridLinePen(int row) { if ( row%12 == 7 ) return wxPen(*wxBLACK, 1, wxSOLID); else return GetDefaultGridLinePen(); }
wxGrid::GetColGridLinePenwxPen GetColGridLinePen(int col) Returns the pen used for vertical grid lines. This virtual function may be overridden in derived classes in order to change the appearance of individual grid lines for the given column col. See GetRowGridLinePen() for an example.
wxGrid::GridLinesEnabledbool GridLinesEnabled() Returns true if drawing of grid lines is turned on, false otherwise.
wxGrid::GetLabelBackgroundColourwxColour GetLabelBackgroundColour() Returns the colour used for the background of row and column labels.
wxGrid::GetLabelFontwxFont GetLabelFont() Returns the font used for row and column labels.
wxGrid::GetLabelTextColourwxColour GetLabelTextColour() Returns the colour used for row and column label text.
wxGrid::GetNumberColsint GetNumberCols() Returns the total number of grid columns (actually the number of columns in the underlying grid table).
wxGrid::GetNumberRowsint GetNumberRows() Returns the total number of grid rows (actually the number of rows in the underlying grid table).
wxGrid::GetOrCreateCellAttrwxGridCellAttr* GetOrCreateCellAttr(int row, int col) const
wxGrid::GetRowMinimalAcceptableHeightint GetRowMinimalAcceptableHeight() This returns the value of the lowest row width that can be handled correctly. See member SetRowMinimalAcceptableHeight for details.
wxGrid::GetRowMinimalHeightint GetRowMinimalHeight(int col) const
wxGrid::GetRowLabelAlignmentvoid GetRowLabelAlignment(int* horiz, int* vert) Sets the arguments to the current row label alignment values.
Horizontal alignment will be one of wxLEFT, wxCENTRE or wxRIGHT. wxPerl note: This method takes no parameters and returns a 2-element list ( horiz, vert ).
wxGrid::GetRowLabelSizeint GetRowLabelSize() Returns the current width of the row labels.
wxGrid::GetRowLabelValuewxString GetRowLabelValue(int row) Returns the specified row label. The default grid table class provides numeric row labels. If you are using a custom grid table you can override wxGridTableBase::GetRowLabelValue to provide your own labels.
wxGrid::GetRowSizeint GetRowSize(int row) Returns the height of the specified row.
wxGrid::GetScrollLineXint GetScrollLineX() const Returns the number of pixels per horizontal scroll increment. The default is 15. See also wxGrid::GetScrollLineY, wxGrid::SetScrollLineX, wxGrid::SetScrollLineY
wxGrid::GetScrollLineYint GetScrollLineY() const Returns the number of pixels per vertical scroll increment. The default is 15. See also wxGrid::GetScrollLineX, wxGrid::SetScrollLineX, wxGrid::SetScrollLineY
wxGrid::GetSelectionModewxGrid::wxGridSelectionModes GetSelectionMode() const Returns the current selection mode, see wxGrid::SetSelectionMode.
wxGrid::GetSelectedCellswxGridCellCoordsArray GetSelectedCells() const Returns an array of singly selected cells.
wxGrid::GetSelectedColswxArrayInt GetSelectedCols() const Returns an array of selected cols.
wxGrid::GetSelectedRowswxArrayInt GetSelectedRows() const Returns an array of selected rows.
wxGrid::GetSelectionBackgroundwxColour GetSelectionBackground() const Access or update the selection fore/back colours
wxGrid::GetSelectionBlockTopLeftwxGridCellCoordsArray GetSelectionBlockTopLeft() const Returns an array of the top left corners of blocks of selected cells, see wxGrid::GetSelectionBlockBottomRight.
wxGrid::GetSelectionBlockBottomRightwxGridCellCoordsArray GetSelectionBlockBottomRight() const Returns an array of the bottom right corners of blocks of selected cells, see wxGrid::GetSelectionBlockTopLeft.
wxGrid::GetSelectionForegroundwxColour GetSelectionForeground() const
wxGrid::GetTablewxGridTableBase * GetTable() const Returns a base pointer to the current table object.
wxGrid::GetViewWidthint GetViewWidth() Returned number of whole cols visible.
wxGrid::HideCellEditControlvoid HideCellEditControl() Hides the in-place cell edit control.
wxGrid::InitColWidthsvoid InitColWidths() Init the m_colWidths/Rights arrays
wxGrid::InitRowHeightsvoid InitRowHeights() NB: never access m_row/col arrays directly because they are created on demand, always use accessor functions instead! Init the m_rowHeights/Bottoms arrays with default values.
wxGrid::InsertColsbool InsertCols(int pos = 0, int numCols = 1, bool updateLabels = true) Inserts one or more new columns into a grid with the first new column at the specified position and returns true if successful. The updateLabels argument is not used at present. The sequence of actions begins with the grid object requesting the underlying grid table to insert new columns. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called wxGrid::CreateGrid) this process is automatic. If you are using a custom grid table (specified with wxGrid::SetTable) then you must override wxGridTableBase::InsertCols in your derived table class.
wxGrid::InsertRowsbool InsertRows(int pos = 0, int numRows = 1, bool updateLabels = true) Inserts one or more new rows into a grid with the first new row at the specified position and returns true if successful. The updateLabels argument is not used at present. The sequence of actions begins with the grid object requesting the underlying grid table to insert new rows. If this is successful the table notifies the grid and the grid updates the display. For a default grid (one where you have called wxGrid::CreateGrid) this process is automatic. If you are using a custom grid table (specified with wxGrid::SetTable) then you must override wxGridTableBase::InsertRows in your derived table class.
wxGrid::IsCellEditControlEnabledbool IsCellEditControlEnabled() const Returns true if the in-place edit control is currently enabled.
wxGrid::IsCurrentCellReadOnlybool IsCurrentCellReadOnly() const Returns true if the current cell has been set to read-only (see wxGrid::SetReadOnly).
wxGrid::IsEditablebool IsEditable() Returns false if the whole grid has been set as read-only or true otherwise. See wxGrid::EnableEditing for more information about controlling the editing status of grid cells.
wxGrid::IsInSelectionbool IsInSelection(int row, int col) const bool IsInSelection(const wxGridCellCoords& coords) const Is this cell currently selected.
wxGrid::IsReadOnlybool IsReadOnly(int row, int col) const Returns true if the cell at the specified location can't be edited. See also wxGrid::IsReadOnly.
wxGrid::IsSelectionbool IsSelection() Returns true if there are currently rows, columns or blocks of cells selected.
wxGrid::IsVisiblebool IsVisible(int row, int col, bool wholeCellVisible = true) bool IsVisible(const wxGridCellCoords& coords, bool wholeCellVisible = true) Returns true if a cell is either wholly visible (the default) or at least partially visible in the grid window.
wxGrid::MakeCellVisiblevoid MakeCellVisible(int row, int col) void MakeCellVisible(const wxGridCellCoords& coords) Brings the specified cell into the visible grid cell area with minimal scrolling. Does nothing if the cell is already visible.
wxGrid::MoveCursorDownbool MoveCursorDown(bool expandSelection) Moves the grid cursor down by one row. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorLeftbool MoveCursorLeft(bool expandSelection) Moves the grid cursor left by one column. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorRightbool MoveCursorRight(bool expandSelection) Moves the grid cursor right by one column. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorUpbool MoveCursorUp(bool expandSelection) Moves the grid cursor up by one row. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorDownBlockbool MoveCursorDownBlock(bool expandSelection) Moves the grid cursor down in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorLeftBlockbool MoveCursorLeftBlock(bool expandSelection) Moves the grid cursor left in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorRightBlockbool MoveCursorRightBlock(bool expandSelection) Moves the grid cursor right in the current row such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MoveCursorUpBlockbool MoveCursorUpBlock(bool expandSelection) Moves the grid cursor up in the current column such that it skips to the beginning or end of a block of non-empty cells. If a block of cells was previously selected it will expand if the argument is true or be cleared if the argument is false.
Keyboard
wxGrid::MovePageDownbool MovePageDown() Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row.
Keyboard
wxGrid::MovePageUpbool MovePageUp() Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row.
Keyboard
wxGrid::RegisterDataTypevoid RegisterDataType(const wxString& typeName, wxGridCellRenderer* renderer, wxGridCellEditor* editor) Methods for a registry for mapping data types to Renderers/Editors
wxGrid::SaveEditControlValuevoid SaveEditControlValue() Sets the value of the current grid cell to the current in-place edit control value. This is called automatically when the grid cursor moves from the current cell to a new cell. It is also a good idea to call this function when closing a grid since any edits to the final cell location will not be saved otherwise.
wxGrid::SelectAllvoid SelectAll() Selects all cells in the grid.
wxGrid::SelectBlockvoid SelectBlock(int topRow, int leftCol, int bottomRow, int rightCol, bool addToSelected = false) void SelectBlock(const wxGridCellCoords& topLeft, const wxGridCellCoords& bottomRight, bool addToSelected = false) Selects a rectangular block of cells. If addToSelected is false then any existing selection will be deselected; if true the column will be added to the existing selection.
wxGrid::SelectColvoid SelectCol(int col, bool addToSelected = false) Selects the specified column. If addToSelected is false then any existing selection will be deselected; if true the column will be added to the existing selection.
wxGrid::SelectionToDeviceRectwxRect SelectionToDeviceRect() This function returns the rectangle that encloses the selected cells in device coords and clipped to the client size of the grid window.
wxGrid::SelectRowvoid SelectRow(int row, bool addToSelected = false) Selects the specified row. If addToSelected is false then any existing selection will be deselected; if true the row will be added to the existing selection.
wxGrid::SetCellAlignmentvoid SetCellAlignment(int row, int col, int horiz, int vert) void SetCellAlignment(int align, int row, int col) Sets the horizontal and vertical alignment for grid cell text at the specified location.
Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT.
wxGrid::SetCellBackgroundColourvoid SetCellBackgroundColour(int row, int col, const wxColour& colour)
wxGrid::SetCellEditorvoid SetCellEditor(int row, int col, wxGridCellEditor* editor) Sets the editor for the grid cell at the specified location. The grid will take ownership of the pointer. See wxGridCellEditor and the wxGrid overview for more information about cell editors and renderers.
wxGrid::SetCellFontvoid SetCellFont(int row, int col, const wxFont& font) Sets the font for text in the grid cell at the specified location.
wxGrid::SetCellRenderervoid SetCellRenderer(int row, int col, wxGridCellRenderer* renderer) Sets the renderer for the grid cell at the specified location. The grid will take ownership of the pointer. See wxGridCellRenderer and the wxGrid overview for more information about cell editors and renderers.
wxGrid::SetCellTextColourvoid SetCellTextColour(int row, int col, const wxColour& colour) void SetCellTextColour(const wxColour& val, int row, int col) void SetCellTextColour(const wxColour& colour) Sets the text colour for the grid cell at the specified location.
wxGrid::SetCellValuevoid SetCellValue(int row, int col, const wxString& s) void SetCellValue(const wxGridCellCoords& coords, const wxString& s) void SetCellValue(const wxString& val, int row, int col) Sets the string value for the cell at the specified location. For simple applications where a grid object automatically uses a default grid table of string values you use this function together with wxGrid::GetCellValue to access cell values. For more complex applications where you have derived your own grid table class that contains various data types (e.g. numeric, boolean or user-defined custom types) then you only use this function for those cells that contain string values. The last form is for backward compatibility only. See wxGridTableBase::CanSetValueAs and the wxGrid overview for more information.
wxGrid::SetColAttrvoid SetColAttr(int col, wxGridCellAttr* attr) Sets the cell attributes for all cells in the specified column. For more information about controlling grid cell attributes see the wxGridCellAttr cell attribute class and the wxGrid classes overview.
wxGrid::SetColFormatBoolvoid SetColFormatBool(int col) Sets the specified column to display boolean values. wxGrid displays boolean values with a checkbox.
wxGrid::SetColFormatNumbervoid SetColFormatNumber(int col) Sets the specified column to display integer values.
wxGrid::SetColFormatFloatvoid SetColFormatFloat(int col, int width = -1, int precision = -1) Sets the specified column to display floating point values with the given width and precision.
wxGrid::SetColFormatCustomvoid SetColFormatCustom(int col, const wxString& typeName) Sets the specified column to display data in a custom format. See the wxGrid overview for more information on working with custom data types.
wxGrid::SetColLabelAlignmentvoid SetColLabelAlignment(int horiz, int vert) Sets the horizontal and vertical alignment of column label text. Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
wxGrid::SetColLabelSizevoid SetColLabelSize(int height) Sets the height of the column labels. If height equals to wxGRID_AUTOSIZE then height is calculated automatically so that no label is truncated. Note that this could be slow for a large table. This flag is new since wxWidgets version 2.8.8.
wxGrid::SetColLabelValuevoid SetColLabelValue(int col, const wxString& value) Set the value for the given column label. If you are using a derived grid table you must override wxGridTableBase::SetColLabelValue for this to have any effect.
wxGrid::SetColMinimalWidthvoid SetColMinimalWidth(int col, int width) Sets the minimal width for the specified column. This should normally be called when creating the grid because it will not resize a column that is already narrower than the minimal width. The width argument must be higher than the minimimal acceptable column width, see wxGrid::GetColMinimalAcceptableWidth.
wxGrid::SetColMinimalAcceptableWidthvoid SetColMinimalAcceptableWidth(int width) This modifies the minimum column width that can be handled correctly. Specifying a low value here allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller than the actual minimum size will incur a performance penalty in the functions which perform grid cell index lookup on the basis of screen coordinates. This should normally be called when creating the grid because it will not resize existing columns with sizes smaller than the value specified here.
wxGrid::SetColPosvoid SetColPos(int colID, int newPos) Sets the position of the specified column.
wxGrid::SetColSizevoid SetColSize(int col, int width) Sets the width of the specified column. This function does not refresh the grid. If you are calling it outside of a BeginBatch / EndBatch block you can use wxGrid::ForceRefresh to see the changes. Automatically sizes the column to fit its contents. If setAsMin is true the calculated width will also be set as the minimal width for the column.
Note
wxGrid::SetDefaultCellAlignmentvoid SetDefaultCellAlignment(int horiz, int vert) Sets the default horizontal and vertical alignment for grid cell text. Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
wxGrid::SetDefaultCellBackgroundColourvoid SetDefaultCellBackgroundColour(const wxColour& colour) Sets the default background colour for grid cells.
wxGrid::SetDefaultCellFontvoid SetDefaultCellFont(const wxFont& font) Sets the default font to be used for grid cell text.
wxGrid::SetDefaultCellTextColourvoid SetDefaultCellTextColour(const wxColour& colour) Sets the current default colour for grid cell text.
wxGrid::SetDefaultEditorvoid SetDefaultEditor(wxGridCellEditor* editor) Sets the default editor for grid cells. The grid will take ownership of the pointer. See wxGridCellEditor and the wxGrid overview for more information about cell editors and renderers.
wxGrid::SetDefaultRenderervoid SetDefaultRenderer(wxGridCellRenderer* renderer) Sets the default renderer for grid cells. The grid will take ownership of the pointer. See wxGridCellRenderer and the wxGrid overview for more information about cell editors and renderers.
wxGrid::SetDefaultColSizevoid SetDefaultColSize(int width, bool resizeExistingCols = false) Sets the default width for columns in the grid. This will only affect columns subsequently added to the grid unless resizeExistingCols is true.
wxGrid::SetDefaultRowSizevoid SetDefaultRowSize(int height, bool resizeExistingRows = false) Sets the default height for rows in the grid. This will only affect rows subsequently added to the grid unless resizeExistingRows is true.
wxGrid::SetGridCursorvoid SetGridCursor(int row, int col) Set the grid cursor to the specified cell. This function calls wxGrid::MakeCellVisible.
wxGrid::SetGridLineColourvoid SetGridLineColour(const wxColour&colour) Sets the colour used to draw grid lines.
wxGrid::SetLabelBackgroundColourvoid SetLabelBackgroundColour(const wxColour& colour) Sets the background colour for row and column labels.
wxGrid::SetLabelFontvoid SetLabelFont(const wxFont& font) Sets the font for row and column labels.
wxGrid::SetLabelTextColourvoid SetLabelTextColour(const wxColour& colour) Sets the colour for row and column label text.
wxGrid::SetMarginsvoid SetMargins(int extraWidth, int extraHeight) A grid may occupy more space than needed for its rows/columns. This function allows to set how big this extra space is
wxGrid::SetOrCalcColumnSizesint SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = true) Common part of AutoSizeColumn/Row() and GetBestSize()
wxGrid::SetOrCalcRowSizesint SetOrCalcRowSizes(bool calcOnly, bool setAsMin = true)
wxGrid::SetReadOnlyvoid SetReadOnly(int row, int col, bool isReadOnly = true) Makes the cell at the specified location read-only or editable. See also wxGrid::IsReadOnly.
wxGrid::SetRowAttrvoid SetRowAttr(int row, wxGridCellAttr* attr) Sets the cell attributes for all cells in the specified row. See the wxGridCellAttr class for more information about controlling cell attributes.
wxGrid::SetRowLabelAlignmentvoid SetRowLabelAlignment(int horiz, int vert) Sets the horizontal and vertical alignment of row label text. Horizontal alignment should be one of wxALIGN_LEFT, wxALIGN_CENTRE or wxALIGN_RIGHT. Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.
wxGrid::SetRowLabelSizevoid SetRowLabelSize(int width) Sets the width of the row labels. If width equals wxGRID_AUTOSIZE then width is calculated automatically so that no label is truncated. Note that this could be slow for a large table. This flag is new since wxWidgets version 2.8.8.
wxGrid::SetRowLabelValuevoid SetRowLabelValue(int row, const wxString& value) Set the value for the given row label. If you are using a derived grid table you must override wxGridTableBase::SetRowLabelValue for this to have any effect.
wxGrid::SetRowMinimalHeightvoid SetRowMinimalHeight(int row, int height) Sets the minimal height for the specified row. This should normally be called when creating the grid because it will not resize a row that is already shorter than the minimal height. The height argument must be higher than the minimimal acceptable row height, see wxGrid::GetRowMinimalAcceptableHeight.
wxGrid::SetRowMinimalAcceptableHeightvoid SetRowMinimalAcceptableHeight(int height) This modifies the minimum row width that can be handled correctly. Specifying a low value here allows smaller grid cells to be dealt with correctly. Specifying a value here which is much smaller than the actual minimum size will incur a performance penalty in the functions which perform grid cell index lookup on the basis of screen coordinates. This should normally be called when creating the grid because it will not resize existing rows with sizes smaller than the value specified here.
wxGrid::SetRowSizevoid SetRowSize(int row, int height) Sets the height of the specified row. This function does not refresh the grid. If you are calling it outside of a BeginBatch / EndBatch block you can use wxGrid::ForceRefresh to see the changes. Automatically sizes the column to fit its contents. If setAsMin is true the calculated width will also be set as the minimal width for the column. Note wxGrid sets up arrays to store individual row and column sizes when non-default sizes are used. The memory requirements for this could become prohibitive if your grid is very large.
wxGrid::SetScrollLineXvoid SetScrollLineX(int x) Sets the number of pixels per horizontal scroll increment. The default is 15. Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding errors: setting this to 1 can help. See also wxGrid::GetScrollLineX, wxGrid::GetScrollLineY, wxGrid::SetScrollLineY
wxGrid::SetScrollLineYvoid SetScrollLineY(int y) Sets the number of pixels per vertical scroll increment. The default is 15. Sometimes wxGrid has trouble setting the scrollbars correctly due to rounding errors: setting this to 1 can help. See also wxGrid::GetScrollLineX, wxGrid::GetScrollLineY, wxGrid::SetScrollLineX
wxGrid::SetSelectionBackgroundvoid SetSelectionBackground(const wxColour& c)
wxGrid::SetSelectionForegroundvoid SetSelectionForeground(const wxColour& c)
wxGrid::SetSelectionModevoid SetSelectionMode(wxGrid::wxGridSelectionModes selmode) Set the selection behaviour of the grid. Parameters wxGrid::wxGridSelectCells
wxGrid::wxGridSelectRows
wxGrid::wxGridSelectColumns
wxGrid::SetTablebool SetTable(wxGridTableBase* table, bool takeOwnership = false, wxGrid::wxGridSelectionModes selmode = wxGrid::wxGridSelectCells) Passes a pointer to a custom grid table to be used by the grid. This should be called after the grid constructor and before using the grid object. If takeOwnership is set to true then the table will be deleted by the wxGrid destructor. Use this function instead of wxGrid::CreateGrid when your application involves complex or non-string data or data sets that are too large to fit wholly in memory.
wxGrid::ShowCellEditControlvoid ShowCellEditControl() Displays the in-place cell edit control for the current cell.
wxGrid::XToColint XToCol(int x, bool clipToMinMax = false) Parameters x
Return value The grid column that corresponds to the logical x coordinate. Returns wxNOT_FOUND if there is no column at the x position.
wxGrid::XToEdgeOfColint XToEdgeOfCol(int x) Returns the column whose right hand edge is close to the given logical x position. If no column edge is near to this position wxNOT_FOUND is returned.
wxGrid::YToEdgeOfRowint YToEdgeOfRow(int y) Returns the row whose bottom edge is close to the given logical y position. If no row edge is near to this position wxNOT_FOUND is returned.
wxGrid::YToRowint YToRow(int y) Returns the grid row that corresponds to the logical y coordinate. Returns wxNOT_FOUND if there is no row at the y position.
|