1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: wxGrid Overview</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
<tbody>
<tr>
<td id="projectlogo">
<a href="http://www.wxwidgets.org/" target="_new">
<img alt="wxWidgets" src="logo.png"/>
</a>
</td>
<td style="padding-left: 0.5em; text-align: right;">
<span id="projectnumber">Version: 3.0.2</span>
</td>
</tr>
</tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main Page</span></a></li>
<li class="current"><a href="pages.html"><span>Related Pages</span></a></li>
<li><a href="modules.html"><span>Categories</span></a></li>
<li><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="index.html">Documentation</a></li><li class="navelem"><a class="el" href="page_topics.html">Programming Guides</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle">
<div class="title"><a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> Overview </div> </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#overview_grid_simpleexample">Getting Started</a></li>
<li class="level1"><a href="#overview_grid_resizing">Column and Row Sizes</a></li>
</ul>
</div>
<div class="textblock"><p><a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> and its related classes are used for displaying and editing tabular data.</p>
<p><a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> supports custom attributes for the table cells, allowing to completely customize its appearance and uses a separate grid table (wxGridTableBase-derived) class for the data management meaning that it can be used to display arbitrary amounts of data.</p>
<h1><a class="anchor" id="overview_grid_simpleexample"></a>
Getting Started</h1>
<p>For simple applications you need only refer to the <a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> class in your code. This example shows how you might create a grid in a frame or dialog constructor and illustrates some of the formatting functions.</p>
<div class="fragment"><div class="line"><span class="comment">// Create a wxGrid object</span></div>
<div class="line"></div>
<div class="line">grid = <span class="keyword">new</span> <a class="code" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a>( <span class="keyword">this</span>,</div>
<div class="line"> -1,</div>
<div class="line"> <a class="code" href="classwx_point.html" title="A wxPoint is a useful data structure for graphics operations.">wxPoint</a>( 0, 0 ),</div>
<div class="line"> <a class="code" href="classwx_size.html" title="A wxSize is a useful data structure for graphics operations.">wxSize</a>( 400, 300 ) );</div>
<div class="line"></div>
<div class="line"><span class="comment">// Then we call CreateGrid to set the dimensions of the grid</span></div>
<div class="line"><span class="comment">// (100 rows and 10 columns in this example)</span></div>
<div class="line">grid->CreateGrid( 100, 10 );</div>
<div class="line"></div>
<div class="line"><span class="comment">// We can set the sizes of individual rows and columns</span></div>
<div class="line"><span class="comment">// in pixels</span></div>
<div class="line">grid->SetRowSize( 0, 60 );</div>
<div class="line">grid->SetColSize( 0, 120 );</div>
<div class="line"></div>
<div class="line"><span class="comment">// And set grid cell contents as strings</span></div>
<div class="line">grid->SetCellValue( 0, 0, <span class="stringliteral">"wxGrid is good"</span> );</div>
<div class="line"></div>
<div class="line"><span class="comment">// We can specify that some cells are read->only</span></div>
<div class="line">grid->SetCellValue( 0, 3, <span class="stringliteral">"This is read->only"</span> );</div>
<div class="line">grid->SetReadOnly( 0, 3 );</div>
<div class="line"></div>
<div class="line"><span class="comment">// Colours can be specified for grid cell contents</span></div>
<div class="line">grid->SetCellValue(3, 3, <span class="stringliteral">"green on grey"</span>);</div>
<div class="line">grid->SetCellTextColour(3, 3, *<a class="code" href="colour_8h.html#a98125a3b5ab1f7bc8dbc7a62e329f142">wxGREEN</a>);</div>
<div class="line">grid->SetCellBackgroundColour(3, 3, *<a class="code" href="colour_8h.html#a76762d1254986a92025f54e7683c3441">wxLIGHT_GREY</a>);</div>
<div class="line"></div>
<div class="line"><span class="comment">// We can specify the some cells will store numeric</span></div>
<div class="line"><span class="comment">// values rather than strings. Here we set grid column 5</span></div>
<div class="line"><span class="comment">// to hold floating point values displayed with width of 6</span></div>
<div class="line"><span class="comment">// and precision of 2</span></div>
<div class="line">grid->SetColFormatFloat(5, 6, 2);</div>
<div class="line">grid->SetCellValue(0, 6, <span class="stringliteral">"3.1415"</span>);</div>
</div><!-- fragment --><p>Here is a list of classes related to <a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a>:</p>
<ul>
<li><a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a>: The main grid control class itself. </li>
<li><a class="el" href="classwx_grid_table_base.html" title="The almost abstract base class for grid tables.">wxGridTableBase</a>: The base class for grid data provider. </li>
<li><a class="el" href="classwx_grid_string_table.html" title="Simplest type of data table for a grid for small tables of strings that are stored in memory...">wxGridStringTable</a>: Simple <a class="el" href="classwx_grid_table_base.html" title="The almost abstract base class for grid tables.">wxGridTableBase</a> implementation supporting only string data items and storing them all in memory (hence suitable for not too large grids only). </li>
<li><a class="el" href="classwx_grid_cell_attr.html" title="This class can be used to alter the cells' appearance in the grid by changing their attributes from t...">wxGridCellAttr</a>: A cell attribute, allowing to customize its appearance as well as the renderer and editor used for displaying and editing it. </li>
<li><a class="el" href="classwx_grid_cell_attr_provider.html" title="Class providing attributes to be used for the grid cells.">wxGridCellAttrProvider</a>: The object responsible for storing and retrieving the cell attributes. </li>
<li>wxGridColLabelWindow: The window showing the grid columns labels. </li>
<li>wxGridRowLabelWindow: The window showing the grid rows labels. </li>
<li>wxGridCornerLabelWindow: The window used in the upper left grid corner. </li>
<li>wxGridWindow: The window representing the main part of the grid. </li>
<li><a class="el" href="classwx_grid_cell_renderer.html" title="This class is responsible for actually drawing the cell in the grid.">wxGridCellRenderer</a>: Base class for objects used to display a cell value. </li>
<li><a class="el" href="classwx_grid_cell_string_renderer.html" title="This class may be used to format string data in a cell; it is the default for string cells...">wxGridCellStringRenderer</a>: Renderer showing the cell as a text string. </li>
<li><a class="el" href="classwx_grid_cell_number_renderer.html" title="This class may be used to format integer data in a cell.">wxGridCellNumberRenderer</a>: Renderer showing the cell as an integer number. </li>
<li><a class="el" href="classwx_grid_cell_float_renderer.html" title="This class may be used to format floating point data in a cell.">wxGridCellFloatRenderer</a>: Renderer showing the cell as a floating point number. </li>
<li><a class="el" href="classwx_grid_cell_bool_renderer.html" title="This class may be used to format boolean data in a cell.">wxGridCellBoolRenderer</a>: Renderer showing the cell as checked or unchecked box. </li>
<li><a class="el" href="classwx_grid_cell_editor.html" title="This class is responsible for providing and manipulating the in-place edit controls for the grid...">wxGridCellEditor</a>: Base class for objects used to edit the cell value. </li>
<li>wxGridCellStringEditor: Editor for cells containing text strings. </li>
<li><a class="el" href="classwx_grid_cell_number_editor.html" title="Grid cell editor for numeric integer data.">wxGridCellNumberEditor</a>: Editor for cells containing integer numbers. </li>
<li><a class="el" href="classwx_grid_cell_float_editor.html" title="The editor for floating point numbers data.">wxGridCellFloatEditor</a>: Editor for cells containing floating point numbers. </li>
<li><a class="el" href="classwx_grid_cell_bool_editor.html" title="Grid cell editor for boolean data.">wxGridCellBoolEditor</a>: Editor for boolean-valued cells. </li>
<li><a class="el" href="classwx_grid_cell_choice_editor.html" title="Grid cell editor for string data providing the user a choice from a list of strings.">wxGridCellChoiceEditor</a>: Editor allowing to choose one of the predefined strings (and possibly enter new one). </li>
<li><a class="el" href="classwx_grid_event.html" title="This event class contains information about various grid events.">wxGridEvent</a>: The event sent by most of <a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> actions. </li>
<li><a class="el" href="classwx_grid_size_event.html" title="This event class contains information about a row/column resize event.">wxGridSizeEvent</a>: The special event sent when a grid column or row is resized. </li>
<li><a class="el" href="classwx_grid_range_select_event.html">wxGridRangeSelectEvent</a>: The special event sent when a range of cells is selected in the grid. </li>
<li><a class="el" href="classwx_grid_editor_created_event.html">wxGridEditorCreatedEvent</a>: The special event sent when a cell editor is created. </li>
<li>wxGridSelection: The object efficiently representing the grid selection. </li>
<li>wxGridTypeRegistry: Contains information about the data types supported by the grid.</li>
</ul>
<h1><a class="anchor" id="overview_grid_resizing"></a>
Column and Row Sizes</h1>
<p><b>NB:</b> This section will discuss the resizing of <a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> rows only to avoid repetitions but everything in it also applies to grid columns, just replace <code>Row</code> in the method names with <code>Col</code>.</p>
<p>Initially all <a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> rows have the same height, which can be modified for all of them at once using <a class="el" href="classwx_grid.html#a5a50adddf3fd511e1aeb40bf1ea4ab62" title="Sets the default height for rows in the grid.">wxGrid::SetDefaultRowSize()</a>. However, unlike simpler controls such as <a class="el" href="classwx_list_box.html" title="A listbox is used to select one or more of a list of strings.">wxListBox</a> or <a class="el" href="classwx_list_ctrl.html" title="A list control presents lists in a number of formats: list view, report view, icon view and small ico...">wxListCtrl</a>, <a class="el" href="classwx_grid.html" title="wxGrid and its related classes are used for displaying and editing tabular data.">wxGrid</a> also allows its rows to be individually resized to have their own height using <a class="el" href="classwx_grid.html#a58ab2f54c69ee51a19fd1b82da49750a" title="Sets the height of the specified row.">wxGrid::SetRowSize()</a> (as a special case, a row may be hidden entirely by setting its size to 0, which is done by a helper <a class="el" href="classwx_grid.html#a246e6e9f6ddadecf5baf5cf80363b129" title="Hides the specified row.">wxGrid::HideRow()</a> method). It is also possible to resize a row to fit its contents with <a class="el" href="classwx_grid.html#a294120495c98eb7d2962b2c811cb5c27" title="Automatically sizes the row to fit its contents.">wxGrid::AutoSizeRow()</a> or do it for all rows at once with <a class="el" href="classwx_grid.html#a83a57fb7b20cb8fc9d9d0cd6124327e0" title="Automatically sizes all rows to fit their contents.">wxGrid::AutoSizeRows()</a>.</p>
<p>Additionally, by default the user can also drag the row separator lines to resize the rows interactively. This can be forbidden completely by calling <a class="el" href="classwx_grid.html#a8649bb2283fdd841cad33a27e7866660" title="Disables row sizing by dragging with the mouse.">wxGrid::DisableDragRowSize()</a> or just for the individual rows using <a class="el" href="classwx_grid.html#ada36932f853ff0294f1faac5923fade6" title="Disable interactive resizing of the specified row.">wxGrid::DisableRowResize()</a>.</p>
<p>If you do allow the user to resize the grid rows, it may be a good idea to save their heights and restore it when the grid is recreated the next time (possibly during a next program execution): the functions <a class="el" href="classwx_grid.html#a943ab0e35ec10c0caf6226a7ee6da37b" title="Get size information for all row at once.">wxGrid::GetRowSizes()</a> and <a class="el" href="classwx_grid.html#a07a8fc5ffab7932e63a3741ea364d958" title="Restore all rows sizes.">wxGrid::SetRowSizes()</a> can help with this, you will just need to serialize <a class="el" href="structwx_grid_sizes_info.html" title="wxGridSizesInfo stores information about sizes of all wxGrid rows or columns.">wxGridSizesInfo</a> structure returned by the former in some way and deserialize it back before calling the latter. </p>
</div></div><!-- contents -->
<address class="footer">
<small>
Generated on Thu Nov 27 2014 13:46:42 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>
|