Grids Reference Page

From Lazarus wiki
Jump to navigationJump to search

Objective

This text will try to show the user some aspects of the grids components in lazarus. Also is intended to serve as a guide for users who never used grids before (as experienced users generally only need a reference for new functionality). So this text will try to reach the following objectives:

  1. To introduce the grids components to people with little or not previous delphi contact.
  2. To document the differences with respect to delphi grids components.
  3. To document the new functionality in lazarus grids.
  4. Create reference and examples for the components.

Overview

A grid is a component that provides a mean for display data in tabular format. The most obvious characteristic of grids is that they are composed of cells forming rows and columns.

The type of information that can be shown in a grid is very ample, mainly depends on what the user wants to show, generally this information is translated in text, colors, imagenes or one combination of them.

Given the great variety of information that can be represented, a series of grids exits whose purpose is to facilitate to the user showing a specific kind of information.

Inheritence Tree

[TCustomComponent]
     |
     |
 TCustomGrid
     |
     |
TCustomDrawGrid
     |
     |
  TDrawGrid
     |
     |
TCustomStringGrid
     |
     |
 TStringGrid

A Starting Example

As one of the objectives of this is to be nice with people with little or no previous lazarus knowledge lets do a quick starting example of grids in action. Why not, lets make a traditional "hello world" example using the TStringGrid Component.

  1. Create a new application.
    • From the main menu select: project->New Project
    • In the Create New Project dialog press the "Create Button"
    • A new empty form will be shown.
  2. Place a grid on the form
    • From the component palette select the "additional" tab
    • Click over the TStringGrid icon []
    • Click over the form, near to the top left corner. A new empty grid appears.
  3. Place a button on the form
    • From the component palette select the "Standard" tab
    • Click over the TButton icon []
    • Click over a empty area of the form. A new button appears.
  4. Doubleclick the button from the step 3, and write down the following code in the click button handler:
    • Stringgrid1.Cells[1,1] := 'Hi World!';
  5. Run the program by clicking the play icon []
    • by pressing the button1, the hello world text should appear in cell column 1, row 1.

Differences between Lazarus and Delphi grids

The current grids components present several differences with respect to the delphi's grids. This is mainly because the lazarus grids were created from scratch primarily without trying to make them fully compatible.

At a later stage, the compatibility with delphi's grids become a desired objective and the grids starting to follow more closely the delphi grid's interface, but still without doing strong efforts to make every single property or method to match the delphi counterpart. Also, because the grid's internals are much different some things are not possible or need to be done in a different way in the lazarus' grids. As the grids were evolved, greater compatibility becomes and is a desired.

Differences

In this place the known differences will be enumerated in no special order.

  • Cell Editors
  • Designtime Behaviour

New Functionality

  • Columns
  • Events
  • Grid Editor

Grids Reference

Grids Howto

Todo