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