Board index » delphi » TStringGrid and multiple lines of text in a single grid

TStringGrid and multiple lines of text in a single grid

Hello all.

I am using the standard TstringGrid that comes with Delphi 4 and am
wondering if there is a way to get more than one line of text to appear in a
single cell in the grid.

For example:

cell 1,1 needs to be:
       student - code
       $30 weekly

Right now I am having to make the column widths very large to put everything
on one line:
       student-code/30-wk

This wastes a lot of space and makes the screen too big.  I'm trying to
avoid having to use a third-party stringgrid, but if I have to I will.

Any help would be appreciated.

Sincerely,
Doug Maurer
Innovative Software Solutions, Ltd.

 

Re:TStringGrid and multiple lines of text in a single grid


Hi !

To do this, you'll have to set DefaultDrawing to false, and paint the contents yourself in
OnDrawDatacell event. of course, you'll have to set the rowheight large enough to fit the text,
could be set with Defaultrowheight.
--

Bjoerge

<<Doug Maurer:
I am using the standard TstringGrid that comes with Delphi 4 and am
wondering if there is a way to get more than one line of text to appear in a
single cell in the grid.

For example:

cell 1,1 needs to be:
       student - code
       $30 weekly

Right now I am having to make the column widths very large to put everything
on one line:
       student-code/30-wk

This wastes a lot of space and makes the screen too big.  I'm trying to
avoid having to use a third-party stringgrid, but if I have to I will.

Quote

Re:TStringGrid and multiple lines of text in a single grid


First you need to write your own ondrawcell event handler and set
defaultdrawing to false.  On www.borland.com you can find Technical document

TI1045D  Different colored characters in a string grid

Gives you the idea of how to do this.

When you use the stringgrid's canvas.textout function you can put text
anywhere on the grid.  So you need to work out your rules on how to split up
your string and then put the parts in three positions in the cell.

If you need more examples of making you ondrawcell routines I can send you
some.
It's not very hard!

Alec Ford

alecf...@clear.net.nz

Quote
Doug Maurer wrote in message <_6Jj3.501$Db7.5...@typ21b.nn.bcandid.com>...
>Hello all.

>I am using the standard TstringGrid that comes with Delphi 4 and am
>wondering if there is a way to get more than one line of text to appear in
a
>single cell in the grid.

>For example:

>cell 1,1 needs to be:
>       student - code
>       $30 weekly

>Right now I am having to make the column widths very large to put
everything
>on one line:
>       student-code/30-wk

>This wastes a lot of space and makes the screen too big.  I'm trying to
>avoid having to use a third-party stringgrid, but if I have to I will.

>Any help would be appreciated.

>Sincerely,
>Doug Maurer
>Innovative Software Solutions, Ltd.

Other Threads