]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tgrid.tex
InsertItems() documented
[wxWidgets.git] / docs / latex / wx / tgrid.tex
CommitLineData
a660d684
KB
1\section{wxGrid classes overview}\label{gridoverview}
2
3wxGrid is a class for displaying and editing tabular information.
4
5To use wxGrid, include the wxgrid.h header file and link with the
6wxGrid library. Create a wxGrid object, or, if you need to override
7some default behaviour, create an object of a class derived from wxGrid.
8You need to call CreateGrid before there are any cells in the grid.
9
10All row and column positions start from zero, and dimensions are in pixels.
11
12If you make changes to row or column dimensions, call UpdateDimensions and
13then AdjustScrollbars. If you make changes to the grid appearance (such as
14a change of cell background colour or font), call Refresh for the changes
15to be shown.
16
17\subsection{Example}
18
19The following fragment is taken from the file samples/grid/test.cpp. Note the
20call to UpdateDimensions, which is required if the application
21has changed any dimensions such as column width or row height.
22You may also need to call AdjustScrollbars. In this case, AdjustScrollbars
23isn't necessary because it will be called by wxGrid::OnSize which is invoked
24when the window is first displayed.
25
26\begin{verbatim}
27 // Make a grid
28 frame->grid = new wxGrid(frame, 0, 0, 400, 400);
29
30 frame->grid->CreateGrid(10, 8);
31 frame->grid->SetColumnWidth(3, 200);
32 frame->grid->SetRowHeight(4, 45);
33 frame->grid->SetCellValue("First cell", 0, 0);
34 frame->grid->SetCellValue("Another cell", 1, 1);
35 frame->grid->SetCellValue("Yet another cell", 2, 2);
36 frame->grid->SetCellTextFont(wxTheFontList->FindOrCreateFont(12, wxROMAN, wxITALIC, wxNORMAL), 0, 0);
37 frame->grid->SetCellTextColour(*wxRED, 1, 1);
38 frame->grid->SetCellBackgroundColour(*wxCYAN, 2, 2);
39 frame->grid->UpdateDimensions();
40\end{verbatim}