1 \section{\class{wxGrid
}}\label{wxgrid
}
3 wxGrid is a class for displaying and editing tabular information.
5 \wxheading{Derived from
}
7 \helpref{wxPanel
}{wxpanel
}\\
8 \helpref{wxWindow
}{wxwindow
}\\
9 \helpref{wxEvtHandler
}{wxevthandler
}\\
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
16 \wxheading{Window styles
}
18 There are no specific window styles for this class.
20 See also
\helpref{window styles overview
}{windowstyles
}.
24 \helpref{wxGrid classes overview
}{gridoverview
}
26 \latexignore{\rtfignore{\wxheading{Members
}}}
28 \membersection{wxGrid::wxGrid
}\label{wxgridconstr
}
30 \func{void
}{wxGrid
}{\param{wxWindow*
}{parent
},
\param{wxWindowID
}{ id
},
\param{const wxPoint\&
}{ pos
},
31 \rtfsp\param{const wxSize\&
}{ size
},
\param{long
}{ style=
0},
\param{const wxString\&
}{name="grid"
}}
33 Constructor. Before using a wxGrid object, you must call CreateGrid to set up the required rows and columns.
35 \membersection{wxGrid::AdjustScrollbars
}\label{wxgridadjustscrollbars
}
37 \func{void
}{AdjustScrollbars
}{\void}
39 Call this function whenever a change has been made via the API that might alter the scrollbar characteristics:
40 particularly when adding or deleting rows, or changing row or column dimensions. For example,
41 removing rows might make it unnecessary to show the vertical scrollbar.
43 \membersection{wxGrid::AppendCols
}\label{wxgridappendcols
}
45 \func{bool
}{AppendCols
}{\param{int
}{ n=
1},
\param{bool
}{ updateLabels=TRUE
}}
47 Appends
{\it n
} columns to the grid. If
{\it updateLabels
} is TRUE,
48 the function OnChangeLabels is called to give the application the opportunity to relabel.
50 \membersection{wxGrid::AppendRows
}\label{wxgridappendrows
}
52 \func{bool
}{AppendRows
}{\param{int
}{ n=
1},
\param{bool
}{ updateLabels=TRUE
}}
54 Appends
{\it n
} rows to the grid. If
{\it updateLabels
} is TRUE,
55 the function OnChangeLabels is called to give the application the opportunity to relabel.
57 \membersection{wxGrid::BeginBatch
}\label{wxgridbeginbatch
}
59 \func{void
}{BeginBatch
}{\void}
61 Start a BeginBatch/EndBatch pair between which, calls to SetCellValue or
62 SetCellBitmap will not cause a refresh. This allows you to speed up some operations
63 (for example, setting several hundred cell values). You can nest, but not overlap,
66 See also
\helpref{wxGrid::EndBatch
}{wxgridendbatch
},
\helpref{wxGrid::GetBatchCount
}{wxgridgetbatchcount
}.
68 \membersection{wxGrid::CellHitTest
}\label{wxgridcellhittest
}
70 \func{bool
}{CellHitTest
}{\param{int
}{ x
},
\param{int
}{ y
},
\param{int *
}{row
},
\param{int *
}{col
}}
72 Returns TRUE if the x, y panel position coincides with a cell. If so,
{\it row
} and
{\it col
} are
75 \membersection{wxGrid::CreateGrid
}\label{wxgridcreategrid
}
77 \func{bool
}{CreateGrid
}{\param{int
}{ rows
},
\param{int
}{ cols
},
\param{wxString **
}{cellValues=NULL
},
78 \param{short *
}{widths=NULL
},
\param{short
}{ defaultWidth=wxGRID
\_DEFAULT\_CELL\_WIDTH},
79 \param{short
}{ defaultHeight=wxGRID
\_DEFAULT\_CELL\_HEIGHT}}
81 Creates a grid
{\it rows
} high and
{\it cols
} wide. You can optionally specify an array of initial values
82 and widths, and/or default cell width and height.
84 Call this function after creating the wxGrid object.
86 \membersection{wxGrid::CurrentCellVisible
}\label{wxgridcurrentcellvisible
}
88 \func{bool
}{CurrentCellVisible
}{\void}
90 Returns TRUE if the currently selected cell is visible, FALSE otherwise.
92 \membersection{wxGrid::DeleteCols
}\label{wxgriddeletecols
}
94 \func{bool
}{DeleteCols
}{\param{int
}{ pos=
0},
\param{int
}{ n=
1},
\param{bool
}{ updateLabels=TRUE
}}
96 Deletes
{\it n
} columns from the grid at position
{\it pos
}. If
{\it updateLabels
} is TRUE,
97 the function OnChangeLabels is called to give the application the opportunity to relabel.
99 \membersection{wxGrid::DeleteRows
}\label{wxgriddeleterows
}
101 \func{bool
}{DeleteRows
}{\param{int
}{ pos=
0},
\param{int
}{ n=
1},
\param{bool
}{ updateLabels=TRUE
}}
103 Deletes
{\it n
} rows from the grid at position
{\it pos
}. If
{\it updateLabels
} is TRUE,
104 the function OnChangeLabels is called to give the application the opportunity to relabel.
106 \membersection{wxGrid::EndBatch
}\label{wxgridendbatch
}
108 \func{void
}{EndBatch
}{\void}
110 End a BeginBatch/EndBatch pair between which, calls to SetCellValue or
111 SetCellBitmap will not cause a refresh. This allows you to speed up some operations
112 (for example, setting several hundred cell values). You can nest, but not overlap,
115 See also
\helpref{wxGrid::BeginBatch
}{wxgridbeginbatch
},
\helpref{wxGrid::GetBatchCount
}{wxgridgetbatchcount
}.
117 \membersection{wxGrid::GetBatchCount
}\label{wxgridgetbatchcount
}
119 \constfunc{int
}{GetBatchCount
}{\void}
121 Return the level of batch nesting. This is initially zero, and will be incremented
122 every time BeginBatch is called, and decremented when EndBatch is called. When the
123 batch count is more zero, some functions (such as SetCellValue and SetCellBitmap) will
124 not refresh the cell.
126 See also
\helpref{wxGrid::BeginBatch
}{wxgridbeginbatch
},
\helpref{wxGrid::EndBatch
}{wxgridendbatch
}.
128 \membersection{wxGrid::GetCell
}\label{wxgridgetcell
}
130 \constfunc{wxGridCell *
}{GetCell
}{\param{int
}{ row
},
\param{int
}{ col
}}
132 Returns the grid cell object associated with this position.
134 wxGenericGrid implementation only.
136 \membersection{wxGrid::GetCellAlignment
}\label{wxgridgetcellalignment
}
138 \constfunc{int
}{GetCellAlignment
}{\param{int
}{ row
},
\param{int
}{ col
}}
140 \constfunc{int
}{GetCellAlignment
}{\void}
142 Sets the text alignment for the cell at the given position, or the global alignment value.
143 The return value is wxLEFT, wxRIGHT or wxCENTRE.
145 \membersection{wxGrid::GetCellBackgroundColour
}\label{wxgridgetcellbackgroundcolour
}
147 \constfunc{wxColour\&
}{GetCellBackgroundColour
}{\param{int
}{ row
},
\param{int
}{ col
}}
149 \constfunc{wxColour\&
}{GetCellBackgroundColour
}{\void}
151 Gets the background colour for the cell at the given position, or the global background colour.
153 \membersection{wxGrid::GetCells
}\label{wxgridgetcells
}
155 \constfunc{wxGridCell ***
}{GetCells
}{\void}
157 Returns the array of grid cell object associated with this wxGrid.
159 \membersection{wxGrid::GetCellTextColour
}\label{wxgridgetcelltextcolour
}
161 \constfunc{wxColour\&
}{GetCellTextColour
}{\param{int
}{ row
},
\param{int
}{ col
}}
163 \constfunc{wxColour\&
}{GetCellTextColour
}{\void}
165 Gets the text colour for the cell at the given position, or the global text colour.
167 \membersection{wxGrid::GetCellTextFont
}\label{wxgridgetcelltextfont
}
169 \constfunc{const wxFont\&
}{GetCellTextFont
}{\param{int
}{ row
},
\param{int
}{ col
}}
171 \constfunc{wxFont\&
}{GetCellTextFont
}{\void}
173 Gets the text font for the cell at the given position, or the global text font.
175 \membersection{wxGrid::GetCellValue
}\label{wxgridgetcellvalue
}
177 \constfunc{wxString\&
}{GetCellValue
}{\param{int
}{ row
},
\param{int
}{ col
}}
179 Returns the cell value at the given position.
181 \membersection{wxGrid::GetCols
}\label{wxgridgetcols
}
183 \constfunc{int
}{GetCols
}{\void}
185 Returns the number of columns in the grid.
187 \membersection{wxGrid::GetColumnWidth
}\label{wxgridcolumnwidth
}
189 \constfunc{int
}{GetColumnWidth
}{\param{int
}{ col
}}
191 Gets the width in pixels for column
{\it col
}.
193 \membersection{wxGrid::GetCurrentRect
}\label{wxgridgetcurrentrect
}
195 \constfunc{wxRectangle *
}{GetCurrentRect
}{\void}
197 Returns a pointer to the rectangle enclosing the currently selected cell.
198 Do not delete this pointer.
200 \membersection{wxGrid::GetCursorColumn
}\label{wxgridgetcursorcolumn
}
202 \constfunc{int
}{GetCursorColumn
}{\void}
204 Returns the column position of the currently selected cell.
206 \membersection{wxGrid::GetCursorRow
}\label{wxgridgetcursorrow
}
208 \constfunc{int
}{GetCursorRow
}{\void}
210 Returns the row position of the currently selected cell.
212 \membersection{wxGrid::GetEditable
}\label{wxgridgeteditable
}
214 \constfunc{bool
}{GetEditable
}{\void}
216 Returns TRUE if the grid cells can be edited.
218 \membersection{wxGrid::GetHorizScrollBar
}\label{wxgridgethorizscrollbar
}
220 \constfunc{wxScrollBar *
}{GetHorizScrollBar
}{\void}
222 Returns a pointer to the horizontal scrollbar.
224 \membersection{wxGrid::GetLabelAlignment
}\label{wxgridgetlabelalignment
}
226 \constfunc{int
}{GetLabelAlignment
}{\param{int
}{ orientation
}}
228 Gets the row or column label alignment.
{\it orientation
} should
229 be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.
\rtfsp
230 {\it alignment
} should be wxCENTRE, wxLEFT or wxRIGHT.
232 \membersection{wxGrid::GetLabelBackgroundColour
}\label{wxgridgetlabelbackgroundcolour
}
234 \constfunc{wxColour\&
}{GetLabelBackgroundColour
}{\void}
236 Gets a row and column label text colour.
238 \membersection{wxGrid::GetLabelSize
}\label{wxgridgetlabelsize
}
240 \constfunc{int
}{GetLabelSize
}{\param{int
}{ orientation
}}
242 Gets the row label height, or column label width, in pixels.
{\it orientation
} should
243 be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.
245 \membersection{wxGrid::GetLabelTextColour
}\label{wxgridgetlabeltextcolour
}
247 \constfunc{wxColour\&
}{GetLabelTextColour
}{\void}
249 Gets a row and column label text colour.
251 \membersection{wxGrid::GetLabelTextFont
}\label{wxgridgetlabeltextfont
}
253 \constfunc{wxFont\&
}{GetLabelTextFont
}{\void}
255 Gets the font to be used for the row and column labels.
257 \membersection{wxGrid::GetLabelValue
}\label{wxgridgetlabelvalue
}
259 \constfunc{wxString\&
}{GetLabelValue
}{\param{int
}{ orientation
},
\param{int
}{ pos
}}
261 Gets a row or column label value.
{\it orientation
} should
262 be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.
\rtfsp
263 {\it pos
} is the label position.
265 \membersection{wxGrid::GetRowHeight
}\label{wxgridgetrowheight
}
267 \constfunc{int
}{GetRowHeight
}{\param{int
}{ row
}}
269 Gets the height in pixels for row
{\it row
}.
271 \membersection{wxGrid::GetRows
}\label{wxgridgetrows
}
273 \constfunc{int
}{GetRows
}{\void}
275 Returns the number of rows in the grid.
277 \membersection{wxGrid::GetScrollPosX
}\label{wxgridgetscrollposx
}
279 \constfunc{int
}{GetScrollPosX
}{\void}
281 Returns the column scroll position.
283 \membersection{wxGrid::GetScrollPosY
}\label{wxgridgetscrollposy
}
285 \constfunc{int
}{GetScrollPosY
}{\void}
287 Returns the row scroll position.
289 \membersection{wxGrid::GetTextItem
}\label{wxgridgettextitem
}
291 \constfunc{wxText *
}{GetTextItem
}{\void}
293 Returns a pointer to the text item used for entering text into a cell.
295 \membersection{wxGrid::GetVertScrollBar
}\label{wxgridgetvertscrollbar
}
297 \constfunc{wxScrollBar *
}{GetVertScrollBar
}{\void}
299 Returns a pointer to the vertical scrollbar.
301 \membersection{wxGrid::InsertCols
}\label{wxgridinsertcols
}
303 \func{bool
}{InsertCols
}{\param{int
}{ pos=
0},
\param{int
}{ n=
1},
\param{bool
}{ updateLabels=TRUE
}}
305 Inserts
{\it n
} number of columns before position
{\it pos
}. If
{\it updateLabels
} is TRUE,
306 the function OnChangeLabels is called to give the application the opportunity to relabel.
308 \membersection{wxGrid::InsertRows
}\label{wxgridinsertrows
}
310 \func{bool
}{InsertRows
}{\param{int
}{ pos=
0},
\param{int
}{ n=
1},
\param{bool
}{ updateLabels=TRUE
}}
312 Inserts
{\it n
} number of rows before position
{\it pos
}. If
{\it updateLabels
} is TRUE,
313 the function OnChangeLabels is called to give the application the opportunity to relabel.
315 \membersection{wxGrid::OnActivate
}\label{wxgridonactivate
}
317 \func{void
}{OnActivate
}{\param{bool
}{ active
}}
319 Sets the text item to have the focus. Call this function when the wxGrid window should have the
320 focus, for example from wxFrame::OnActivate.
322 \membersection{wxGrid::OnChangeLabels
}\label{wxgridonchangelabels
}
324 \func{void
}{OnChangeLabels
}{\void}
326 Called when rows and columns are created or deleted, to allow the application an
327 opportunity to update the labels. By default, columns are labelled alphabetically,
328 and rows numerically.
330 \membersection{wxGrid::OnChangeSelectionLabel
}\label{wxgridonchangeselectionlabel
}
332 \func{void
}{OnChangeSelectionLabel
}{\void}
334 Called when a cell is selected, to allow the application an
335 opportunity to update the selection label (the label of the wxText item
336 used for entering cell text). By default, the cell column letter and row
337 number are concatenated to form the selection label.
339 \membersection{wxGrid::OnCreateCell
}\label{wxgridoncreatecell
}
341 \func{wxGridCell *
}{OnCreateCell
}{\void}
343 Override this virtual function if you want to replace the normal wxGridCell with a derived
346 \membersection{wxGrid::OnCellLeftClick
}\label{wxgridoncellleftclick
}
348 \func{void
}{OnLeftClick
}{\param{int
}{ row
},
\param{int
}{ col
},
\param{int
}{ x
},
\param{int
}{ y
},
\param{bool
}{ control
},
\param{bool
}{ shift
}}
350 Virtual function called when the left button is depressed within a cell, just after OnSelectCell is called.
352 \membersection{wxGrid::OnCellRightClick
}\label{wxgridoncellrightclick
}
354 \func{void
}{OnRightClick
}{\param{int
}{ row
},
\param{int
}{ col
},
\param{int
}{ x
},
\param{int
}{ y
},
\param{bool
}{ control
},
\param{bool
}{ shift
}}
356 Virtual function called when the right button is depressed within a cell, just after OnSelectCell is called.
358 \membersection{wxGrid::OnLabelLeftClick
}\label{wxgridonlabelleftclick
}
360 \func{void
}{OnLeftClick
}{\param{int
}{ row
},
\param{int
}{ col
},
\param{int
}{ x
},
\param{int
}{ y
},
\param{bool
}{ control
},
\param{bool
}{ shift
}}
362 Virtual function called when the left button is depressed within a
365 {\it row
} will be
{\it -
1} if the click is in the top labels.
367 {\it col
} will be
{\it -
1} if the click is in the left labels.
369 {\it row
} and
{\it col
} will be
{\it -
1} if the click is in the upper
372 \membersection{wxGrid::OnLabelRightClick
}\label{wxgridonlabelrightclick
}
374 \func{void
}{OnRightClick
}{\param{int
}{ row
},
\param{int
}{ col
},
\param{int
}{ x
},
\param{int
}{ y
},
\param{bool
}{ control
},
\param{bool
}{ shift
}}
376 Virtual function called when the right button is depressed within a label.
378 {\it row
} will be
{\it -
1} if the click is in the top labels.
380 {\it col
} will be
{\it -
1} if the click is in the left labels.
382 {\it row
} and
{\it col
} will be
{\it -
1} if the click is in the upper
385 \membersection{wxGrid::OnSelectCell
}\label{wxgridonselectcell
}
387 \func{void
}{OnSelectCell
}{\param{int
}{ row
},
\param{int
}{ col
}}
389 Virtual function called when the user left-clicks on a cell.
391 \membersection{wxGrid::OnSelectCellImplementation
}\label{wxgridonselectcellimplementation
}
393 \func{void
}{OnSelectCellImplementation
}{\param{wxDC *
}{dc
},
\param{int
}{ row
},
\param{int
}{ col
}}
395 Virtual function called when the user left-clicks on a cell. If you override this function,
396 call wxGrid::OnSelectCell to apply the default behaviour.
398 \membersection{wxGrid::SetCellAlignment
}\label{wxgridsetcellalignment
}
400 \func{void
}{SetCellAlignment
}{\param{int
}{ alignment
},
\param{int
}{ row
},
\param{int
}{ col
}}
402 \func{void
}{SetCellAlignment
}{\param{int
}{ alignment
}}
404 Sets the text alignment for the cell at the given position, or for the whole grid.
{\it alignment
} may be wxLEFT, wxRIGHT or wxCENTRE.
406 \membersection{wxGrid::SetCellBackgroundColour
}\label{wxgridsetcellbackgroundcolour
}
408 \func{void
}{SetCellBackgroundColour
}{\param{const wxColour\&
}{ colour
},
\param{int
}{ row
},
\param{int
}{ col
}}
410 \func{void
}{SetCellBackgroundColour
}{\param{const wxColour\&
}{ colour
}}
412 Sets the background colour for the cell at the given position, or for the whole grid.
414 \membersection{wxGrid::SetCellTextColour
}\label{wxgridsetcelltextcolour
}
416 \func{void
}{SetCellTextColour
}{\param{const wxColour\&
}{ colour
},
\param{int
}{ row
},
\param{int
}{ col
}}
418 \func{void
}{SetCellTextColour
}{\param{const wxColour\&
}{ colour
}}
420 Sets the text colour for the cell at the given position, or for the whole grid.
422 \membersection{wxGrid::SetCellTextFont
}\label{wxgridsetcelltextfont
}
424 \func{void
}{SetCellTextFont
}{\param{const wxFont\&
}{ font
},
\param{int
}{ row
},
\param{int
}{ col
}}
426 \func{void
}{SetCellTextFont
}{\param{const wxFont\&
}{ font
}}
428 Sets the text font for the cell at the given position, or for the whole grid.
430 \membersection{wxGrid::SetCellValue
}\label{wxgridsetcellvalue
}
432 \func{void
}{SetCellValue
}{\param{const wxString\&
}{ val
},
\param{int
}{ row
},
\param{int
}{ col
}}
434 Sets the cell value at the given position.
436 \membersection{wxGrid::SetColumnWidth
}\label{wxgridsetcolumnwidth
}
438 \func{void
}{SetColumnWidth
}{\param{int
}{ col
},
\param{int
}{ width
}}
440 Sets the width in pixels for column
{\it col
}.
442 \membersection{wxGrid::SetDividerPen
}\label{wxgridsetdividerpen
}
444 \func{void
}{SetDividerPen
}{\param{const wxPen\&
}{ pen
}}
446 Specifies the pen to be used for drawing the divisions between cells. The default
447 is a light grey. If NULL is specified, the divisions will not be drawn.
449 \membersection{wxGrid::SetEditable
}\label{wxgridseteditable
}
451 \func{void
}{SetEditable
}{\param{bool
}{ editable
}}
453 If
{\it editable
} is TRUE (the default), the grid cells will be editable by means of the
454 text edit control. If FALSE, the text edit control will be hidden and the user will not
455 be able to edit the cell contents.
457 \membersection{wxGrid::SetGridCursor
}\label{wxgridsetgridcursor
}
459 \func{void
}{SetGridCursor
}{\param{int
}{row
},
\param{int
}{ col
}}
461 Sets the position of the selected cell.
463 \membersection{wxGrid::SetLabelAlignment
}\label{wxgridsetlabelalignment
}
465 \func{void
}{SetLabelAlignment
}{\param{int
}{ orientation
},
\param{int
}{ alignment
}}
467 Sets the row or column label alignment.
{\it orientation
} should
468 be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.
\rtfsp
469 {\it alignment
} should be wxCENTRE, wxLEFT or wxRIGHT.
471 \membersection{wxGrid::SetLabelBackgroundColour
}\label{wxgridsetlabelbackgroundcolour
}
473 \func{void
}{SetLabelBackgroundColour
}{\param{const wxColour\&
}{ value
}}
475 Sets a row or column label background colour.
477 \membersection{wxGrid::SetLabelSize
}\label{wxgridsetlabelsize
}
479 \func{void
}{SetLabelSize
}{\param{int
}{ orientation
},
\param{int
}{ size
}}
481 Sets the row label height, or column label width, in pixels.
{\it orientation
} should
482 be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.
484 If a dimension of zero is specified, the row or column labels will not be
487 \membersection{wxGrid::SetLabelTextColour
}\label{wxgridsetlabeltextcolour
}
489 \func{void
}{SetLabelTextColour
}{\param{const wxColour\&
}{ value
}}
491 Sets a row and column label text colour.
493 \membersection{wxGrid::SetLabelTextFont
}\label{wxgridsetlabeltextfont
}
495 \func{void
}{SetLabelTextFont
}{\param{const wxFont\&
}{ font
}}
497 Sets the font to be used for the row and column labels.
499 \membersection{wxGrid::SetLabelValue
}\label{wxgridsetlabelvalue
}
501 \func{void
}{SetLabelValue
}{\param{int
}{ orientation
},
\param{const wxString\&
}{ value
},
\param{int
}{ pos
}}
503 Sets a row or column label value.
{\it orientation
} should
504 be wxHORIZONTAL to specify column label, wxVERTICAL to specify row label.
\rtfsp
505 {\it pos
} is the label position.
507 \membersection{wxGrid::SetRowHeight
}\label{wxgridsetrowheight
}
509 \func{void
}{SetRowHeight
}{\param{int
}{ row
},
\param{int
}{ height
}}
511 Sets the height in pixels for row
{\it row
}.
513 \membersection{wxGrid::UpdateDimensions
}\label{wxgridupdatedimensions
}
515 \func{void
}{UpdateDimensions
}{\void}
517 Call this function whenever a change has been made via the API that
518 might alter size characteristics. You may also need to follow it with
519 a call to AdjustScrollbars.