TStringGrid
by
James M Sandbrook of Tokoroa, New Zealand.
Loading text into one of the cells:
StringGrid1.Cells[c, r] := 'TStringGrid';
Example: StringGrid1.Cells[4, 4] := 'TStringGrid';
|
Loading text into one of the cells
at the
top of the (Fixed Row)
TStringGrid:
StringGrid1.Cells[1, 0] := 'Name:';
|
Adding two cells numbers together to
get an
answer:
procedure TForm1.Button1Click(Sender: TObject);
|
To change the Grid Lines width use:
procedure TForm1.Button2Click(Sender: TObject);
|
Many things that work with TStringGrid, work with TDrawGrid.
.... |
To make the vertical line that separates each column from the
next
column invisible, set the Object Inspector property: Options -
goVertLine
- to False.
To make the horizontal line that separates each row from the next row invisible, set the Object Inspector property: Options - goHorzLine - to False. .... |
To make the TStringGrid only allow the user to select one
cell at a
time during run-time,
set the Object Inspector property: Options - RangeSelect - to False. .... |
To make the TStringGrid not allow users to resize the rows in
run-time,
set the
Object Inspector property: Options - goRowSizing - to False. To make the TStringGrid not allow users to resize the columns in run-time, set the Object Inspector property: Options - goColSizing - to False. .... |
To make the TStringGrid not allow users to re-arrange the
columns,
set the Object
Inspector property: Options - goColMoving - to False. To make the TStringGrid not allow users to re-arrange the rows, set the Object Inspector property: Options - goRowMoving - to False. .... |
To make the TStringGrid words editable during run-time, set
the Object
Inspector
property: Options - goEditing - to True. .... |
To have the tabs set up for the TStringGrid, so that the user
can tab
through the
cells of the TStringGrid at run-time, set the Object Inspector property: Options - goTabs - to True. .... |
If you want the user to be able to select a whole row at a
time in
the TStringGrid at run-time,
set the Object Inspector property: Options - goRowSelect - to True. .... |
The amount of columns in your TStringGrid can be changed in
the Object
Inspector property: ColCount. .... |
The amount of rows in your TStringGrid can be changed in the
Object
Inspector property: RowCount. .... |
To change how thick the lines in your TStringGrid are, change
the Object
Inspector property: GridLineWidth. .... |
To change the amount of Fixed columns, change the Object
Inspector
property: FixedCols.
To change the amount of Fixed rows, change the Object
Inspector property:
FixedRows.
|
The Object Inspector property: 'FixedColor' changes the color
of the
thick heading blocks.
The Object Inspector property: 'Color' changes the color of
the cells.
|
The Object Inspector property: 'DefaultColWidth' makes all of
the columns
in the TStringGrid
be as wide as the number you put in the Object Inspector property: 'DefaultColWidth'. This can be changed for the different columns by placing the mouse cursor over the bar that is at the end of the column you would like to make wider, and when the Split cursor comes visible, drag the mouse to the size you would like the cell to be. .... |
The Object Inspector property: 'DefaultRowHeight' makes all
of the
rows in the TStringGrid
be as high as the number you put in the Object Inspector property: 'DefaultRowHeight'. This can be changed for the different rows by placing the mouse cursor over the bar that is at the bottom of the row you would like to make higher, and when the Split cursor comes visible, drag the mouse to the size you would like the row cells to be. .... |
From Greg
Liefs Delphi Question and Answer web page!
MULTI-LINE COLUMN HEADINGS IN A STRINGGRID: Q. I'd like to display multi-line column headings in a TStringGrid. A. First, you need to set the grid's DefaultDrawing property
to False.
Next, you should use the
procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col,
Row: Longint;
Now you can embed a semi-colon to denote a line break in the
column
heading. Also remember
StringGrid1.RowHeights[0] := StringGrid1.DefaultRowHeight * 2 ; |