]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/tgrid.tex
added support for vertical toolbars for MSW - seems to work more or less
[wxWidgets.git] / docs / latex / wx / tgrid.tex
1 \section{wxGrid classes overview}\label{gridoverview}
2
3 wxGrid is a class for displaying and editing tabular information.
4
5 To use wxGrid, include the wxgrid.h header file and link with the
6 wxGrid library. Create a wxGrid object, or, if you need to override
7 some default behaviour, create an object of a class derived from wxGrid.
8 You need to call CreateGrid before there are any cells in the grid.
9
10 All row and column positions start from zero, and dimensions are in pixels.
11
12 If you make changes to row or column dimensions, call UpdateDimensions and
13 then AdjustScrollbars. If you make changes to the grid appearance (such as
14 a change of cell background colour or font), call Refresh for the changes
15 to be shown.
16
17 \subsection{Example}
18
19 The following fragment is taken from the file samples/grid/test.cpp. Note the
20 call to UpdateDimensions, which is required if the application
21 has changed any dimensions such as column width or row height.
22 You may also need to call AdjustScrollbars. In this case, AdjustScrollbars
23 isn't necessary because it will be called by wxGrid::OnSize which is invoked
24 when 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}