Contents Up Previous Next

wxGrid

wxGrid 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
wxWindow
wxEvtHandler
wxObject

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.

EVT_GRID_CELL_LEFT_CLICK(func) The user clicked a cell with the left mouse button. Processes a wxEVT_GRID_CELL_LEFT_CLICK.
EVT_GRID_CELL_RIGHT_CLICK(func) The user clicked a cell with the right mouse button. Processes a wxEVT_GRID_CELL_RIGHT_CLICK.
EVT_GRID_CELL_LEFT_DCLICK(func) The user double-clicked a cell with the left mouse button. Processes a wxEVT_GRID_CELL_LEFT_DCLICK.
EVT_GRID_CELL_RIGHT_DCLICK(func) The user double-clicked a cell with the right mouse button. Processes a wxEVT_GRID_CELL_RIGHT_DCLICK.
EVT_GRID_LABEL_LEFT_CLICK(func) The user clicked a label with the left mouse button. Processes a wxEVT_GRID_LABEL_LEFT_CLICK.
EVT_GRID_LABEL_RIGHT_CLICK(func) The user clicked a label with the right mouse button. Processes a wxEVT_GRID_LABEL_RIGHT_CLICK.
EVT_GRID_LABEL_LEFT_DCLICK(func) The user double-clicked a label with the left mouse button. Processes a wxEVT_GRID_LABEL_LEFT_DCLICK.
EVT_GRID_LABEL_RIGHT_DCLICK(func) The user double-clicked a label with the right mouse button. Processes a wxEVT_GRID_LABEL_RIGHT_DCLICK.
EVT_GRID_CELL_CHANGE(func) The user changed the data in a cell. Processes a wxEVT_GRID_CELL_CHANGE.
EVT_GRID_SELECT_CELL(func) The user moved to, and selected a cell. Processes a wxEVT_GRID_SELECT_CELL.
EVT_GRID_EDITOR_HIDDEN(func) The editor for a cell was hidden. Processes a wxEVT_GRID_EDITOR_HIDDEN.
EVT_GRID_EDITOR_SHOWN(func) The editor for a cell was shown. Processes a wxEVT_GRID_EDITOR_SHOWN.
EVT_GRID_CMD_CELL_LEFT_CLICK(id, func) The user clicked a cell with the left mouse button; variant taking a window identifier. Processes a wxEVT_GRID_CELL_LEFT_CLICK.
EVT_GRID_CMD_CELL_RIGHT_CLICK(id, func) The user clicked a cell with the right mouse button; variant taking a window identifier. Processes a wxEVT_GRID_CELL_RIGHT_CLICK.
EVT_GRID_CMD_CELL_LEFT_DCLICK(id, func) The user double-clicked a cell with the left mouse button; variant taking a window identifier. Processes a wxEVT_GRID_CELL_LEFT_DCLICK.
EVT_GRID_CMD_CELL_RIGHT_DCLICK(id, func) The user double-clicked a cell with the right mouse button; variant taking a window identifier. Processes a wxEVT_GRID_CELL_RIGHT_DCLICK.
EVT_GRID_CMD_LABEL_LEFT_CLICK(id, func) The user clicked a label with the left mouse button; variant taking a window identifier. Processes a wxEVT_GRID_LABEL_LEFT_CLICK.
EVT_GRID_CMD_LABEL_RIGHT_CLICK(id, func) The user clicked a label with the right mouse button; variant taking a window identifier. Processes a wxEVT_GRID_LABEL_RIGHT_CLICK.
EVT_GRID_CMD_LABEL_LEFT_DCLICK(id, func) The user double-clicked a label with the left mouse button; variant taking a window identifier. Processes a wxEVT_GRID_LABEL_LEFT_DCLICK.
EVT_GRID_CMD_LABEL_RIGHT_DCLICK(id, func) The user double-clicked a label with the right mouse button; variant taking a window identifier. Processes a wxEVT_GRID_LABEL_RIGHT_DCLICK.
EVT_GRID_CMD_CELL_CHANGE(id, func) The user changed the data in a cell; variant taking a window identifier. Processes a wxEVT_GRID_CELL_CHANGE.
EVT_GRID_CMD_SELECT_CELL(id, func) The user moved to, and selected a cell; variant taking a window identifier. Processes a wxEVT_GRID_SELECT_CELL.
EVT_GRID_CMD_EDITOR_HIDDEN(id, func) The editor for a cell was hidden; variant taking a window identifier. Processes a wxEVT_GRID_EDITOR_HIDDEN.
EVT_GRID_CMD_EDITOR_SHOWN(id, func) The editor for a cell was shown; variant taking a window identifier. Processes a wxEVT_GRID_EDITOR_SHOWN.
The event handler for the following functions takes a wxGridSizeEvent parameter. The ..._CMD_... variants also take a window identifier.

EVT_GRID_COL_SIZE(func) The user resized a column by dragging it. Processes a wxEVT_GRID_COL_SIZE.
EVT_GRID_ROW_SIZE(func) The user resized a row by dragging it. Processes a wxEVT_GRID_ROW_SIZE.
EVT_GRID_CMD_COL_SIZE(func) The user resized a column by dragging it; variant taking a window identifier. Processes a wxEVT_GRID_COL_SIZE.
EVT_GRID_CMD_ROW_SIZE(func) The user resized a row by dragging it; variant taking a window identifier. Processes a wxEVT_GRID_ROW_SIZE.
The event handler for the following functions takes a wxGridRangeSelectEvent parameter. The ..._CMD_... variant also takes a window identifier.

EVT_GRID_RANGE_SELECT(func) The user selected a group of contiguous cells. Processes a wxEVT_GRID_RANGE_SELECT.
EVT_GRID_CMD_RANGE_SELECT(id, func) The user selected a group of contiguous cells; variant taking a window identifier. Processes a wxEVT_GRID_RANGE_SELECT.
The event handler for the following functions takes a wxGridEditorCreatedEvent parameter. The ..._CMD_... variant also takes a window identifier.

EVT_GRID_EDITOR_CREATED(func) The editor for a cell was created. Processes a wxEVT_GRID_EDITOR_CREATED.
EVT_GRID_CMD_EDITOR_CREATED(id, func) The editor for a cell was created; variant taking a window identifier. Processes a wxEVT_GRID_EDITOR_CREATED.
See also

wxGrid overview

Function groups

Constructors and initialization
Display format
Selection functions
wxGrid::wxGrid
wxGrid::~wxGrid
wxGrid::AppendCols
wxGrid::AppendRows
wxGrid::AutoSize
wxGrid::AutoSizeColOrRow
wxGrid::AutoSizeColumn
wxGrid::AutoSizeColumns
wxGrid::AutoSizeRow
wxGrid::AutoSizeRows
wxGrid::BeginBatch
wxGrid::BlockToDeviceRect
wxGrid::CanDragColSize
wxGrid::CanDragRowSize
wxGrid::CanDragGridSize
wxGrid::CanEnableCellControl
wxGrid::CanHaveAttributes
wxGrid::CellToRect
wxGrid::ClearGrid
wxGrid::ClearSelection
wxGrid::CreateGrid
wxGrid::DeleteCols
wxGrid::DeleteRows
wxGrid::DisableCellEditControl
wxGrid::DisableDragColSize
wxGrid::DisableDragGridSize
wxGrid::DisableDragRowSize
wxGrid::EnableCellEditControl
wxGrid::EnableDragColSize
wxGrid::EnableDragGridSize
wxGrid::EnableDragRowSize
wxGrid::EnableEditing
wxGrid::EnableGridLines
wxGrid::EndBatch
wxGrid::Fit
wxGrid::ForceRefresh
wxGrid::GetBatchCount
wxGrid::GetCellAlignment
wxGrid::GetCellBackgroundColour
wxGrid::GetCellEditor
wxGrid::GetCellFont
wxGrid::GetCellRenderer
wxGrid::GetCellTextColour
wxGrid::GetCellValue
wxGrid::GetColLeft
wxGrid::GetColLabelAlignment
wxGrid::GetColLabelSize
wxGrid::GetColLabelValue
wxGrid::GetColMinimalAcceptableWidth
wxGrid::GetColMinimalWidth
wxGrid::GetColRight
wxGrid::GetColSize
wxGrid::GetDefaultCellAlignment
wxGrid::GetDefaultCellBackgroundColour
wxGrid::GetDefaultCellFont
wxGrid::GetDefaultCellTextColour
wxGrid::GetDefaultColLabelSize
wxGrid::GetDefaultColSize
wxGrid::GetDefaultEditor
wxGrid::GetDefaultEditorForCell
wxGrid::GetDefaultEditorForType
wxGrid::GetDefaultRenderer
wxGrid::GetDefaultRendererForCell
wxGrid::GetDefaultRendererForType
wxGrid::GetDefaultRowLabelSize
wxGrid::GetDefaultRowSize
wxGrid::GetGridCursorCol
wxGrid::GetGridCursorRow
wxGrid::GetGridLineColour
wxGrid::GridLinesEnabled
wxGrid::GetLabelBackgroundColour
wxGrid::GetLabelFont
wxGrid::GetLabelTextColour
wxGrid::GetNumberCols
wxGrid::GetNumberRows
wxGrid::GetOrCreateCellAttr
wxGrid::GetRowMinimalAcceptableHeight
wxGrid::GetRowMinimalHeight
wxGrid::GetRowLabelAlignment
wxGrid::GetRowLabelSize
wxGrid::GetRowLabelValue
wxGrid::GetRowSize
wxGrid::GetScrollLineX
wxGrid::GetScrollLineY
wxGrid::GetSelectionMode
wxGrid::GetSelectedCells
wxGrid::GetSelectedCols
wxGrid::GetSelectedRows
wxGrid::GetSelectionBackground
wxGrid::GetSelectionBlockTopLeft
wxGrid::GetSelectionBlockBottomRight
wxGrid::GetSelectionForeground
wxGrid::GetTable
wxGrid::GetViewWidth
wxGrid::HideCellEditControl
wxGrid::InitColWidths
wxGrid::InitRowHeights
wxGrid::InsertCols
wxGrid::InsertRows
wxGrid::IsCellEditControlEnabled
wxGrid::IsCurrentCellReadOnly
wxGrid::IsEditable
wxGrid::IsInSelection
wxGrid::IsReadOnly
wxGrid::IsSelection
wxGrid::IsVisible
wxGrid::MakeCellVisible
wxGrid::MoveCursorDown
wxGrid::MoveCursorLeft
wxGrid::MoveCursorRight
wxGrid::MoveCursorUp
wxGrid::MoveCursorDownBlock
wxGrid::MoveCursorLeftBlock
wxGrid::MoveCursorRightBlock
wxGrid::MoveCursorUpBlock
wxGrid::MovePageDown
wxGrid::MovePageUp
wxGrid::RegisterDataType
wxGrid::SaveEditControlValue
wxGrid::SelectAll
wxGrid::SelectBlock
wxGrid::SelectCol
wxGrid::SelectionToDeviceRect
wxGrid::SelectRow
wxGrid::SetCellAlignment
wxGrid::SetCellBackgroundColour
wxGrid::SetCellEditor
wxGrid::SetCellFont
wxGrid::SetCellRenderer
wxGrid::SetCellTextColour
wxGrid::SetCellValue
wxGrid::SetColAttr
wxGrid::SetColFormatBool
wxGrid::SetColFormatNumber
wxGrid::SetColFormatFloat
wxGrid::SetColFormatCustom
wxGrid::SetColLabelAlignment
wxGrid::SetColLabelSize
wxGrid::SetColLabelValue
wxGrid::SetColMinimalWidth
wxGrid::SetColMinimalAcceptableWidth
wxGrid::SetColSize
wxGrid::SetDefaultCellAlignment
wxGrid::SetDefaultCellBackgroundColour
wxGrid::SetDefaultCellFont
wxGrid::SetDefaultCellTextColour
wxGrid::SetDefaultEditor
wxGrid::SetDefaultRenderer
wxGrid::SetDefaultColSize
wxGrid::SetDefaultRowSize
wxGrid::SetGridCursor
wxGrid::SetGridLineColour
wxGrid::SetLabelBackgroundColour
wxGrid::SetLabelFont
wxGrid::SetLabelTextColour
wxGrid::SetMargins
wxGrid::SetOrCalcColumnSizes
wxGrid::SetOrCalcRowSizes
wxGrid::SetReadOnly
wxGrid::SetRowAttr
wxGrid::SetRowLabelAlignment
wxGrid::SetRowLabelSize
wxGrid::SetRowLabelValue
wxGrid::SetRowMinimalHeight
wxGrid::SetRowMinimalAcceptableHeight
wxGrid::SetRowSize
wxGrid::SetScrollLineX
wxGrid::SetScrollLineY
wxGrid::SetSelectionBackground
wxGrid::SetSelectionForeground
wxGrid::SetSelectionMode
wxGrid::SetTable
wxGrid::ShowCellEditControl
wxGrid::XToCol
wxGrid::XToEdgeOfCol
wxGrid::YToEdgeOfRow
wxGrid::YToRow


Constructors and initialization

wxGrid
~wxGrid
CreateGrid
SetTable


Display format


Selection functions

wxGrid::ClearSelection
wxGrid::IsSelection
wxGrid::SelectAll
wxGrid::SelectBlock
wxGrid::SelectCol
wxGrid::SelectRow


wxGrid::wxGrid

wxGrid()

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::AppendCols

bool 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::AppendRows

bool 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::AutoSize

void AutoSize()

Automatically sets the height and width of all rows and columns to fit their contents.

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::AutoSizeColOrRow

void AutoSizeColOrRow(int n, bool setAsMin, bool column)

Common part of AutoSizeColumn/Row() or row?


wxGrid::AutoSizeColumn

void 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 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::AutoSizeColumns

void 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 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::AutoSizeRow

void 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 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::AutoSizeRows

void 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 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::BeginBatch

void 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::BlockToDeviceRect

wxRect 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::CanDragColSize

bool 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::CanDragRowSize

bool 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::CanDragGridSize

bool CanDragGridSize()

Return true if the dragging of grid lines to resize rows and columns is enabled or false otherwise.


wxGrid::CanEnableCellControl

bool 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::CanHaveAttributes

bool CanHaveAttributes()

Do we have some place to store attributes in?


wxGrid::CellToRect

wxRect 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::ClearGrid

void 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::ClearSelection

void ClearSelection()

Deselects all cells that are currently selected.


wxGrid::CreateGrid

bool 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::DeleteCols

bool 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::DeleteRows

bool 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::DisableCellEditControl

void DisableCellEditControl()

Disables in-place editing of grid cells. Equivalent to calling EnableCellEditControl(false).


wxGrid::DisableDragColSize

void DisableDragColSize()

Disables column sizing by dragging with the mouse. Equivalent to passing false to wxGrid::EnableDragColSize.


wxGrid::DisableDragGridSize

void DisableDragGridSize()

Disable mouse dragging of grid lines to resize rows and columns. Equivalent to passing false to wxGrid::EnableDragGridSize


wxGrid::DisableDragRowSize

void DisableDragRowSize()

Disables row sizing by dragging with the mouse. Equivalent to passing false to wxGrid::EnableDragRowSize.


wxGrid::EnableCellEditControl

void 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::EnableDragColSize

void EnableDragColSize(bool enable = true)

Enables or disables column sizing by dragging with the mouse.


wxGrid::EnableDragGridSize

void EnableDragGridSize(bool enable = true)

Enables or disables row and column resizing by dragging gridlines with the mouse.


wxGrid::EnableDragRowSize

void EnableDragRowSize(bool enable = true)

Enables or disables row sizing by dragging with the mouse.


wxGrid::EnableEditing

void 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::EnableGridLines

void EnableGridLines(bool enable = true)

Turns the drawing of grid lines on or off.


wxGrid::EndBatch

void 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::Fit

void Fit()

Overridden wxWindow method.


wxGrid::ForceRefresh

void ForceRefresh()

Causes immediate repainting of the grid. Use this instead of the usual wxWindow::Refresh.


wxGrid::GetBatchCount

int 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::GetCellAlignment

void 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.
Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.

wxPerl note: This method only takes the parameters row and col and returns a 2-element list ( horiz, vert ).


wxGrid::GetCellBackgroundColour

wxColour GetCellBackgroundColour(int row, int col)

Returns the background colour of the cell at the specified location.


wxGrid::GetCellEditor

wxGridCellEditor* 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::GetCellFont

wxFont GetCellFont(int row, int col)

Returns the font for text in the grid cell at the specified location.


wxGrid::GetCellRenderer

wxGridCellRenderer* 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::GetCellTextColour

wxColour GetCellTextColour(int row, int col)

Returns the text colour for the grid cell at the specified location.


wxGrid::GetCellValue

wxString 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::GetColLeft

int GetColLeft(int col) const


wxGrid::GetColLabelAlignment

void 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.
Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.

wxPerl note: This method takes no parameters and returns a 2-element list ( horiz, vert ).


wxGrid::GetColLabelSize

int GetColLabelSize()

Returns the current height of the column labels.


wxGrid::GetColLabelValue

wxString 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::GetColMinimalAcceptableWidth

int GetColMinimalAcceptableWidth()

This returns the value of the lowest column width that can be handled correctly. See member SetColMinimalAcceptableWidth for details.


wxGrid::GetColMinimalWidth

int GetColMinimalWidth(int col) const

Get the minimal width of the given column/row.


wxGrid::GetColRight

int GetColRight(int col) const


wxGrid::GetColSize

int GetColSize(int col)

Returns the width of the specified column.


wxGrid::GetDefaultCellAlignment

void 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.
Vertical alignment will be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.


wxGrid::GetDefaultCellBackgroundColour

wxColour GetDefaultCellBackgroundColour()

Returns the current default background colour for grid cells.


wxGrid::GetDefaultCellFont

wxFont GetDefaultCellFont()

Returns the current default font for grid cell text.


wxGrid::GetDefaultCellTextColour

wxColour GetDefaultCellTextColour()

Returns the current default colour for grid cell text.


wxGrid::GetDefaultColLabelSize

int GetDefaultColLabelSize()

Returns the default height for column labels.


wxGrid::GetDefaultColSize

int GetDefaultColSize()

Returns the current default width for grid columns.


wxGrid::GetDefaultEditor

wxGridCellEditor* 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::GetDefaultEditorForCell

wxGridCellEditor* GetDefaultEditorForCell(int row, int col) const

wxGridCellEditor* GetDefaultEditorForCell(const wxGridCellCoords& c) const


wxGrid::GetDefaultEditorForType

wxGridCellEditor* GetDefaultEditorForType(const wxString& typeName) const


wxGrid::GetDefaultRenderer

wxGridCellRenderer* 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::GetDefaultRendererForCell

wxGridCellRenderer* GetDefaultRendererForCell(int row, int col) const


wxGrid::GetDefaultRendererForType

wxGridCellRenderer* GetDefaultRendererForType(const wxString& typeName) const


wxGrid::GetDefaultRowLabelSize

int GetDefaultRowLabelSize()

Returns the default width for the row labels.


wxGrid::GetDefaultRowSize

int GetDefaultRowSize()

Returns the current default height for grid rows.


wxGrid::GetGridCursorCol

int GetGridCursorCol()

Returns the current grid cell column position.


wxGrid::GetGridCursorRow

int GetGridCursorRow()

Returns the current grid cell row position.


wxGrid::GetGridLineColour

wxColour GetGridLineColour()

Returns the colour used for grid lines.


wxGrid::GridLinesEnabled

bool GridLinesEnabled()

Returns true if drawing of grid lines is turned on, false otherwise.


wxGrid::GetLabelBackgroundColour

wxColour GetLabelBackgroundColour()

Returns the colour used for the background of row and column labels.


wxGrid::GetLabelFont

wxFont GetLabelFont()

Returns the font used for row and column labels.


wxGrid::GetLabelTextColour

wxColour GetLabelTextColour()

Returns the colour used for row and column label text.


wxGrid::GetNumberCols

int GetNumberCols()

Returns the total number of grid columns (actually the number of columns in the underlying grid table).


wxGrid::GetNumberRows

int GetNumberRows()

Returns the total number of grid rows (actually the number of rows in the underlying grid table).


wxGrid::GetOrCreateCellAttr

wxGridCellAttr* GetOrCreateCellAttr(int row, int col) const


wxGrid::GetRowMinimalAcceptableHeight

int GetRowMinimalAcceptableHeight()

This returns the value of the lowest row width that can be handled correctly. See member SetRowMinimalAcceptableHeight for details.


wxGrid::GetRowMinimalHeight

int GetRowMinimalHeight(int col) const


wxGrid::GetRowLabelAlignment

void 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.
Vertical alignment will be one of wxTOP, wxCENTRE or wxBOTTOM.

wxPerl note: This method takes no parameters and returns a 2-element list ( horiz, vert ).


wxGrid::GetRowLabelSize

int GetRowLabelSize()

Returns the current width of the row labels.


wxGrid::GetRowLabelValue

wxString 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::GetRowSize

int GetRowSize(int row)

Returns the height of the specified row.


wxGrid::GetScrollLineX

int GetScrollLineX() const

Returns the number of pixels per horizontal scroll increment. The default is 15.

See also

wxGrid::GetScrollLineY, wxGrid::SetScrollLineX, wxGrid::SetScrollLineY


wxGrid::GetScrollLineY

int GetScrollLineY() const

Returns the number of pixels per vertical scroll increment. The default is 15.

See also

wxGrid::GetScrollLineX, wxGrid::SetScrollLineX, wxGrid::SetScrollLineY


wxGrid::GetSelectionMode

wxGrid::wxGridSelectionModes GetSelectionMode() const

Returns the current selection mode, see wxGrid::SetSelectionMode.


wxGrid::GetSelectedCells

wxGridCellCoordsArray GetSelectedCells() const

Returns an array of singly selected cells.


wxGrid::GetSelectedCols

wxArrayInt GetSelectedCols() const

Returns an array of selected cols.


wxGrid::GetSelectedRows

wxArrayInt GetSelectedRows() const

Returns an array of selected rows.


wxGrid::GetSelectionBackground

wxColour GetSelectionBackground() const

Access or update the selection fore/back colours


wxGrid::GetSelectionBlockTopLeft

wxGridCellCoordsArray GetSelectionBlockTopLeft() const

Returns an array of the top left corners of blocks of selected cells, see wxGrid::GetSelectionBlockBottomRight.


wxGrid::GetSelectionBlockBottomRight

wxGridCellCoordsArray GetSelectionBlockBottomRight() const

Returns an array of the bottom right corners of blocks of selected cells, see wxGrid::GetSelectionBlockTopLeft.


wxGrid::GetSelectionForeground

wxColour GetSelectionForeground() const


wxGrid::GetTable

wxGridTableBase * GetTable() const

Returns a base pointer to the current table object.


wxGrid::GetViewWidth

int GetViewWidth()

Returned number of whole cols visible.


wxGrid::HideCellEditControl

void HideCellEditControl()

Hides the in-place cell edit control.


wxGrid::InitColWidths

void InitColWidths()

Init the m_colWidths/Rights arrays


wxGrid::InitRowHeights

void 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::InsertCols

bool 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::InsertRows

bool 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::IsCellEditControlEnabled

bool IsCellEditControlEnabled() const

Returns true if the in-place edit control is currently enabled.


wxGrid::IsCurrentCellReadOnly

bool IsCurrentCellReadOnly() const

Returns true if the current cell has been set to read-only (see wxGrid::SetReadOnly).


wxGrid::IsEditable

bool 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::IsInSelection

bool IsInSelection(int row, int col) const

bool IsInSelection(const wxGridCellCoords& coords) const

Is this cell currently selected.


wxGrid::IsReadOnly

bool IsReadOnly(int row, int col) const

Returns true if the cell at the specified location can't be edited. See also wxGrid::IsReadOnly.


wxGrid::IsSelection

bool IsSelection()

Returns true if there are currently rows, columns or blocks of cells selected.


wxGrid::IsVisible

bool 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::MakeCellVisible

void 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::MoveCursorDown

bool 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
This function is called for Down cursor key presses or Shift+Down to expand a selection.


wxGrid::MoveCursorLeft

bool 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
This function is called for Left cursor key presses or Shift+Left to expand a selection.


wxGrid::MoveCursorRight

bool 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
This function is called for Right cursor key presses or Shift+Right to expand a selection.


wxGrid::MoveCursorUp

bool 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
This function is called for Up cursor key presses or Shift+Up to expand a selection.


wxGrid::MoveCursorDownBlock

bool 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
This function is called for the Ctrl+Down key combination. Shift+Ctrl+Down expands a selection.


wxGrid::MoveCursorLeftBlock

bool 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
This function is called for the Ctrl+Left key combination. Shift+Ctrl+left expands a selection.


wxGrid::MoveCursorRightBlock

bool 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
This function is called for the Ctrl+Right key combination. Shift+Ctrl+Right expands a selection.


wxGrid::MoveCursorUpBlock

bool 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
This function is called for the Ctrl+Up key combination. Shift+Ctrl+Up expands a selection.


wxGrid::MovePageDown

bool MovePageDown()

Moves the grid cursor down by some number of rows so that the previous bottom visible row becomes the top visible row.

Keyboard
This function is called for PgDn keypresses.


wxGrid::MovePageUp

bool MovePageUp()

Moves the grid cursor up by some number of rows so that the previous top visible row becomes the bottom visible row.

Keyboard
This function is called for PgUp keypresses.


wxGrid::RegisterDataType

void RegisterDataType(const wxString& typeName, wxGridCellRenderer* renderer, wxGridCellEditor* editor)

Methods for a registry for mapping data types to Renderers/Editors


wxGrid::SaveEditControlValue

void 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::SelectAll

void SelectAll()

Selects all cells in the grid.


wxGrid::SelectBlock

void 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::SelectCol

void 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::SelectionToDeviceRect

wxRect 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::SelectRow

void 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::SetCellAlignment

void 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.
Vertical alignment should be one of wxALIGN_TOP, wxALIGN_CENTRE or wxALIGN_BOTTOM.


wxGrid::SetCellBackgroundColour

void SetCellBackgroundColour(int row, int col, const wxColour& colour)


wxGrid::SetCellEditor

void 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::SetCellFont

void SetCellFont(int row, int col, const wxFont& font)

Sets the font for text in the grid cell at the specified location.


wxGrid::SetCellRenderer

void 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::SetCellTextColour

void 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::SetCellValue

void 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::SetColAttr

void 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::SetColFormatBool

void SetColFormatBool(int col)

Sets the specified column to display boolean values. wxGrid displays boolean values with a checkbox.


wxGrid::SetColFormatNumber

void SetColFormatNumber(int col)

Sets the specified column to display integer values.


wxGrid::SetColFormatFloat

void 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::SetColFormatCustom

void 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::SetColLabelAlignment

void 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::SetColLabelSize

void SetColLabelSize(int height)

Sets the height of the column labels.


wxGrid::SetColLabelValue

void 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::SetColMinimalWidth

void 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::SetColMinimalAcceptableWidth

void 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::SetColSize

void 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 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::SetDefaultCellAlignment

void 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::SetDefaultCellBackgroundColour

void SetDefaultCellBackgroundColour(const wxColour& colour)

Sets the default background colour for grid cells.


wxGrid::SetDefaultCellFont

void SetDefaultCellFont(const wxFont& font)

Sets the default font to be used for grid cell text.


wxGrid::SetDefaultCellTextColour

void SetDefaultCellTextColour(const wxColour& colour)

Sets the current default colour for grid cell text.


wxGrid::SetDefaultEditor

void 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::SetDefaultRenderer

void 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::SetDefaultColSize

void 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::SetDefaultRowSize

void 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::SetGridCursor

void SetGridCursor(int row, int col)

Set the grid cursor to the specified cell. This function calls wxGrid::MakeCellVisible.


wxGrid::SetGridLineColour

void SetGridLineColour(const wxColour&colour)

Sets the colour used to draw grid lines.


wxGrid::SetLabelBackgroundColour

void SetLabelBackgroundColour(const wxColour& colour)

Sets the background colour for row and column labels.


wxGrid::SetLabelFont

void SetLabelFont(const wxFont& font)

Sets the font for row and column labels.


wxGrid::SetLabelTextColour

void SetLabelTextColour(const wxColour& colour)

Sets the colour for row and column label text.


wxGrid::SetMargins

void 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::SetOrCalcColumnSizes

int SetOrCalcColumnSizes(bool calcOnly, bool setAsMin = true)

Common part of AutoSizeColumn/Row() and GetBestSize()


wxGrid::SetOrCalcRowSizes

int SetOrCalcRowSizes(bool calcOnly, bool setAsMin = true)


wxGrid::SetReadOnly

void SetReadOnly(int row, int col, bool isReadOnly = true)

Makes the cell at the specified location read-only or editable. See also wxGrid::IsReadOnly.


wxGrid::SetRowAttr

void 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::SetRowLabelAlignment

void 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::SetRowLabelSize

void SetRowLabelSize(int width)

Sets the width of the row labels.


wxGrid::SetRowLabelValue

void 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::SetRowMinimalHeight

void 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::SetRowMinimalAcceptableHeight

void 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::SetRowSize

void 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::SetScrollLineX

void 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::SetScrollLineY

void 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::SetSelectionBackground

void SetSelectionBackground(const wxColour& c)


wxGrid::SetSelectionForeground

void SetSelectionForeground(const wxColour& c)


wxGrid::SetSelectionMode

void SetSelectionMode(wxGrid::wxGridSelectionModes selmode)

Set the selection behaviour of the grid.

Parameters

wxGrid::wxGridSelectCells

wxGrid::wxGridSelectRows

wxGrid::wxGridSelectColumns


wxGrid::SetTable

bool 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::ShowCellEditControl

void ShowCellEditControl()

Displays the in-place cell edit control for the current cell.


wxGrid::XToCol

int XToCol(int x)

Returns the grid column that corresponds to the logical x coordinate. Returns wxNOT_FOUND if there is no column at the x position.


wxGrid::XToEdgeOfCol

int 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::YToEdgeOfRow

int 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::YToRow

int 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.