When you place a new grid component on a form, it contains one fixed row and one fixed column by default.

Depho Graphs

In its appearance, the grid can have lines of different sizes, or it can have no lines. You can set the size of each column or row independently of the others because the RowSize, ColWidth, and RowHeight properties are arrays. For the grid's behavior, you can let the user resize the columns and the rows (goColSizing and goRowSizing), drag entire columns and rows to a new position (goRowMoving and goColumnMoving), select automatic editing, and allow range selections. Because various options allow users to perform a number of operations on grids, there are also a number of events related to grids, such as OnColumnMoved, OnDrawCell, or OnSetEditText.

The most important event is probably OnDrawCell. In response to this event, a program has to paint a certain cell of the grid. Only string grids can automatically display their contents. The DrawGrid, in fact, doesn't have support for storing data. It is simply a tool for arranging a portion of the screen to display information in a regular format. It is a simple tool but also a powerful one. Methods such Cell-Rect, which returns the rectangle corresponding to the area of a cell, or MouseTo-Cell, which returns the cell in a specific location, are a joy to use. By handling resizable rows and columns and scrollable grids, they simplify complex tasks and spare the programmer from tedious calculations.

What can you use a grid for? Building a spreadsheet is probably the first idea that comes to mind, but that's probably a little too complex for an example. I've decided to use the StringGrid control in a program that shows the fonts installed in the system and the DrawGrid control in a program that emulates the MineSweeper game.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment