📄 grid.tex
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name: grid.tex%% Purpose: wxGrid%% Author:%% Modified by: Santiago Palacios%% Created:%% RCS-ID: $Id: grid.tex,v 1.34 2006/07/24 23:16:26 VZ Exp $%% Copyright: (c) wxWidgets%% License: wxWindows license%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{\class{wxGrid}}\label{wxgrid}wxGrid and its related classes are used for displaying and editing tabulardata. They provide a rich set of features for display, editing, andinteracting with a variety of data sources. For simple applications, and tohelp you get started, wxGrid is the only class you need to refer todirectly. It will set up default instances of the other classes and managethem for you. For more complex applications you can derive your ownclasses for custom grid views, grid data tables, cell editors andrenderers. The \helpref{wxGrid classes overview}{gridoverview} hasexamples of simple and more complex applications, explains therelationship between the various grid classes and has a summary of thekeyboard shortcuts and mouse functions provided by wxGrid.wxGrid has been greatly expanded and redesigned for wxWidgets 2.2onwards. If you have been using the old wxGrid class you will probablywant to have a look at the \helpref{wxGrid classes overview}{gridoverview} to seehow things have changed. The new grid classes are reasonably backward-compatiblebut there are some exceptions. There are also easier ways of doing many things compared tothe previous implementation.\wxheading{Derived from}\helpref{wxScrolledWindow}{wxscrolledwindow}\\\helpref{wxWindow}{wxwindow}\\\helpref{wxEvtHandler}{wxevthandler}\\\helpref{wxObject}{wxobject}\wxheading{Include files}<wx/grid.h>\wxheading{Window styles}There are presently no specific window styles for wxGrid.\wxheading{Event handling}\input gridevt.incThe event handler for the following functions takes a \helpref{wxGridSizeEvent}{wxgridsizeevent} parameter.The ...\_CMD\_... variants also take a window identifier.\twocolwidtha{7cm}\begin{twocollist}\itemsep=0pt\twocolitem{{\bf EVT\_GRID\_COL\_SIZE(func)}}{The user resized a column by dragging it. Processes a wxEVT\_GRID\_COL\_SIZE.}\twocolitem{{\bf EVT\_GRID\_ROW\_SIZE(func)}}{The user resized a row by dragging it. Processes a wxEVT\_GRID\_ROW\_SIZE.}\twocolitem{{\bf 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.}\twocolitem{{\bf 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.}\end{twocollist}%The event handler for the following functions takes a \helpref{wxGridRangeSelectEvent}{wxgridrangeselectevent} parameter.The ...\_CMD\_... variant also takes a window identifier.\twocolwidtha{7cm}\begin{twocollist}\itemsep=0pt\twocolitem{{\bf EVT\_GRID\_RANGE\_SELECT(func)}}{The user selected a group of contiguous cells. Processes a wxEVT\_GRID\_RANGE\_SELECT.}\twocolitem{{\bf 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.}\end{twocollist}%The event handler for the following functions takes a \helpref{wxGridEditorCreatedEvent}{wxgrideditorcreatedevent} parameter.The ...\_CMD\_... variant also takes a window identifier.\twocolwidtha{7cm}\begin{twocollist}\itemsep=0pt\twocolitem{{\bf EVT\_GRID\_EDITOR\_CREATED(func)}}{The editor for a cell was created. Processes a wxEVT\_GRID\_EDITOR\_CREATED.}\twocolitem{{\bf 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.}\end{twocollist}%\wxheading{See also}\helpref{wxGrid overview}{gridoverview}%%%%%%%%%%% FUNCTION GROUPS %%%%%%%%%%%%%\latexignore{\rtfignore{\wxheading{Function groups}}}\membersection{Constructors and initialization}\label{wxgridconstructors}\helpref{wxGrid}{wxgridctor}\\\helpref{\destruct{wxGrid}}{wxgriddtor}\\\helpref{CreateGrid}{wxgridcreategrid}\\\helpref{SetTable}{wxgridsettable}\membersection{Display format}\label{wxgriddisplayformat}\membersection{Selection functions}\label{wxgridselectionfunctions}\helpref{wxGrid::ClearSelection}{wxgridclearselection}\\\helpref{wxGrid::IsSelection}{wxgridisselection}\\\helpref{wxGrid::SelectAll}{wxgridselectall}\\\helpref{wxGrid::SelectBlock}{wxgridselectblock}\\\helpref{wxGrid::SelectCol}{wxgridselectcol}\\\helpref{wxGrid::SelectRow}{wxgridselectrow}%%%%%%%%% MEMBER FUNCTIONS %%%%%%%%%%\helponly{\insertatlevel{2}{\wxheading{Members}}}\membersection{wxGrid::wxGrid}\label{wxgridctor}\func{}{wxGrid}{\void}Default constructor\func{}{wxGrid}{\param{wxWindow* }{parent}, \param{wxWindowID }{id}, \param{const wxPoint\& }{pos = wxDefaultPosition}, \param{const wxSize\& }{size = wxDefaultSize}, \param{long }{style = wxWANTS\_CHARS}, \param{const wxString\& }{name = wxPanelNameStr}}Constructor to create a grid object. Call either \helpref{wxGrid::CreateGrid}{wxgridcreategrid} or\helpref{wxGrid::SetTable}{wxgridsettable} directly after this to initialize the grid before usingit.\membersection{wxGrid::\destruct{wxGrid}}\label{wxgriddtor}\func{}{\destruct{wxGrid}}{\void}Destructor. This will also destroy the associated grid table unless you passed a tableobject to the grid and specified that the grid should not take ownership of thetable (see \helpref{wxGrid::SetTable}{wxgridsettable}).\membersection{wxGrid::AppendCols}\label{wxgridappendcols}\func{bool}{AppendCols}{\param{int }{numCols = 1}, \param{bool }{updateLabels = true}}Appends one or more new columns to the right of the grid and returns true ifsuccessful. The updateLabels argument is not used at present.If you are using a derived grid table class you will need to override\helpref{wxGridTableBase::AppendCols}{wxgridtablebaseappendcols}. See\helpref{wxGrid::InsertCols}{wxgridinsertcols} for further information.\membersection{wxGrid::AppendRows}\label{wxgridappendrows}\func{bool}{AppendRows}{\param{int }{numRows = 1}, \param{bool }{updateLabels = true}}Appends one or more new rows to the bottom of the grid and returns true ifsuccessful. The updateLabels argument is not used at present.If you are using a derived grid table class you will need to override\helpref{wxGridTableBase::AppendRows}{wxgridtablebaseappendrows}. See\helpref{wxGrid::InsertRows}{wxgridinsertrows} for further information.\membersection{wxGrid::AutoSize}\label{wxgridautosize}\func{void}{AutoSize}{\void}Automatically sets the height and width of all rows and columns to fit their contents.\wxheading{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.\membersection{wxGrid::AutoSizeColOrRow}\label{wxgridautosizecolorrow}\func{void}{AutoSizeColOrRow}{\param{int }{n}, \param{bool }{setAsMin}, \param{bool }{column}}Common part of AutoSizeColumn/Row() or row?\membersection{wxGrid::AutoSizeColumn}\label{wxgridautosizecolumn}\func{void}{AutoSizeColumn}{\param{int }{col}, \param{bool }{setAsMin = true}}Automatically sizes the column to fit its contents. If setAsMin is true the calculated width willalso be set as the minimal width for the column.\wxheading{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.\membersection{wxGrid::AutoSizeColumns}\label{wxgridautosizecolumns}\func{void}{AutoSizeColumns}{\param{bool }{setAsMin = true}}Automatically sizes all columns to fit their contents. If setAsMin is true the calculated widths willalso be set as the minimal widths for the columns.\wxheading{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.\membersection{wxGrid::AutoSizeRow}\label{wxgridautosizerow}\func{void}{AutoSizeRow}{\param{int }{row}, \param{bool }{setAsMin = true}}Automatically sizes the row to fit its contents. If setAsMin is true the calculated height willalso be set as the minimal height for the row.\wxheading{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.\membersection{wxGrid::AutoSizeRows}\label{wxgridautosizerows}\func{void}{AutoSizeRows}{\param{bool }{setAsMin = true}}Automatically sizes all rows to fit their contents. If setAsMin is true the calculated heights willalso be set as the minimal heights for the rows.\wxheading{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.\membersection{wxGrid::BeginBatch}\label{wxgridbeginbatch}\func{void}{BeginBatch}{\void}Increments the grid's batch count. When the count is greater than zero repainting ofthe grid is suppressed. Each call to BeginBatch must be matched by a later call to\helpref{wxGrid::EndBatch}{wxgridendbatch}. Code that does a lot of gridmodification can be enclosed between BeginBatch and EndBatch calls to avoidscreen flicker. The final EndBatch will cause the grid to be repainted.\membersection{wxGrid::BlockToDeviceRect}\label{wxgridblocktodevicerect}\func{wxRect}{BlockToDeviceRect}{\param{const wxGridCellCoords \& }{topLeft}, \param{const wxGridCellCoords \& }{bottomRight}}This function returns the rectangle that encloses the block of cellslimited by TopLeft and BottomRight cell in device coords and clippedto the client size of the grid window.\membersection{wxGrid::CanDragColMove}\label{wxgridcandragcolmove}\func{bool}{CanDragColMove}{\void}Returns true if columns can be moved by dragging with the mouse. Columns can be movedby dragging on their labels.\membersection{wxGrid::CanDragColSize}\label{wxgridcandragcolsize}\func{bool}{CanDragColSize}{\void}Returns true if columns can be resized by dragging with the mouse. Columns can be resizedby dragging the edges of their labels. If grid line dragging is enabled they can also beresized by dragging the right edge of the column in the grid cell area(see \helpref{wxGrid::EnableDragGridSize}{wxgridenabledraggridsize}).\membersection{wxGrid::CanDragRowSize}\label{wxgridcandragrowsize}\func{bool}{CanDragRowSize}{\void}Returns true if rows can be resized by dragging with the mouse. Rows can be resizedby dragging the edges of their labels. If grid line dragging is enabled they can also beresized by dragging the lower edge of the row in the grid cell area(see \helpref{wxGrid::EnableDragGridSize}{wxgridenabledraggridsize}).\membersection{wxGrid::CanDragGridSize}\label{wxgridcandraggridsize}\func{bool}{CanDragGridSize}{\void}Return true if the dragging of grid lines to resize rows and columns is enabled or false otherwise.\membersection{wxGrid::CanEnableCellControl}\label{wxgridcanenablecellcontrol}\constfunc{bool}{CanEnableCellControl}{\void}Returns true if the in-place edit control for the current grid cell can be used andfalse otherwise (e.g. if the current cell is read-only).\membersection{wxGrid::CanHaveAttributes}\label{wxgridcanhaveattributes}\func{bool}{CanHaveAttributes}{\void}Do we have some place to store attributes in?\membersection{wxGrid::CellToRect}\label{wxgridcelltorect}\func{wxRect}{CellToRect}{\param{int }{row}, \param{int }{col}}\func{wxRect}{CellToRect}{\param{const wxGridCellCoords\& }{coords}}Return the rectangle corresponding to the grid cell's size and position in logicalcoordinates.\membersection{wxGrid::ClearGrid}\label{wxgridcleargrid}\func{void}{ClearGrid}{\void}Clears all data in the underlying grid table and repaints the grid. The table is not deleted bythis function. If you are using a derived table class then you need to override\helpref{wxGridTableBase::Clear}{wxgridtablebaseclear} for this function to have any effect.\membersection{wxGrid::ClearSelection}\label{wxgridclearselection}\func{void}{ClearSelection}{\void}Deselects all cells that are currently selected.\membersection{wxGrid::CreateGrid}\label{wxgridcreategrid}\func{bool}{CreateGrid}{\param{int }{numRows}, \param{int }{numCols}, \param{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 thisfunction wxGrid will create and manage a simple table of string valuesfor you. All of the grid data will be stored in memory.For applications with more complex data types or relationships, or fordealing with very large datasets, you should derive your own grid tableclass and pass a table object to the grid with \helpref{wxGrid::SetTable}{wxgridsettable}.\membersection{wxGrid::DeleteCols}\label{wxgriddeletecols}\func{bool}{DeleteCols}{\param{int }{pos = 0}, \param{int }{numCols = 1}, \param{bool }{updateLabels = true}}Deletes one or more columns from a grid starting at the specified position and returnstrue if successful. The updateLabels argument is not used at present.If you are using a derived grid table class you will need to override\helpref{wxGridTableBase::DeleteCols}{wxgridtablebasedeletecols}. See\helpref{wxGrid::InsertCols}{wxgridinsertcols} for further information.\membersection{wxGrid::DeleteRows}\label{wxgriddeleterows}\func{bool}{DeleteRows}{\param{int }{pos = 0}, \param{int }{numRows = 1}, \param{bool }{updateLabels = true}}Deletes one or more rows from a grid starting at the specified position and returnstrue if successful. The updateLabels argument is not used at present.If you are using a derived grid table class you will need to override\helpref{wxGridTableBase::DeleteRows}{wxgridtablebasedeleterows}. See\helpref{wxGrid::InsertRows}{wxgridinsertrows} for further information.\membersection{wxGrid::DisableCellEditControl}\label{wxgriddisablecelleditcontrol}\func{void}{DisableCellEditControl}{\void}Disables in-place editing of grid cells.Equivalent to calling EnableCellEditControl(false).\membersection{wxGrid::DisableDragColMove}\label{wxgriddisabledragcolmove}\func{void}{DisableDragColMove}{\void}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -