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