Creating a grid layout
You can position fields in rows and columns on a screen to create a grid by using the GridFieldManager class. When you create a grid, you can specify the number of rows and columns. After you create a grid, you cannot change the number of rows and columns that it contains.
Grids are zero-indexed, so the first cell is located at row 0, column 0. In a locale with a left-to-right text direction, the first cell is in the upper-left corner of the grid.
In a locale with a right-to-left text direction, the first cell is in the upper-right corner of the grid.
You can add fields to a grid sequentially (left-to right, top-to-bottom in locales with a left-to-right text direction; right-to-left, top-to-bottom in locales with a right-to-left text direction) or by specifying a row and column in the grid. You can delete fields, insert fields, specify the spacing between columns and rows, and retrieve a grid's properties.
Grids do not have defined heading rows or heading columns. You can emulate the appearance of headings by changing the appearance of the fields in the grid's first row or first column.
Grids can scroll horizontally or vertically if the grid's width or height exceeds the screen's visible area.
You can specify column width by invoking GridFieldManager.setColumnProperty(), and you can specify row height by invoking GridFieldManager.setRowProperty(). When you invoke these methods, you must specify a GridFieldManager property.
| Property | Description |
|---|---|
| FIXED_SIZE | width or height is a fixed size in pixels |
| PREFERRED_SIZE | width or height is a preferred size based on the maximum preferred size of the fields in the column or row (PREFERRED_SIZE is the default property) |
| PREFERRED_SIZE_WITH_MAXIMUM | width or height is a preferred size up to a maximum size |
| AUTO_SIZE | width or height is based on available screen space |