Board index » delphi » How to draw multiple line text in a cell in TStringGrid

How to draw multiple line text in a cell in TStringGrid

Hi, is there a easy way to draw multiple line text in a cell of a
TStringGrid?
Thanks.

--
=============================================
Jack Wu
Global Investment Systems
j...@gisltd.com

 

Re:How to draw multiple line text in a cell in TStringGrid


Depends what easy is...you could use DrawText to do the job - it will not
draw inside the inplace edit though!!

// draws ALL cells as multiline (including fixed cells - you can exclude
them,,)
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  s: string;
begin
  with StringGrid1, Canvas do
  begin
    FillRect(Rect);
    s := Cells[ACol,ARow];
    InflateRect(Rect, -2, -2);
    DrawText(Handle, PChar(s), Length(s), Rect, DT_WORDBREAK or
DT_NOPREFIX);
  end;
end;

Hope this is what you are looking for...

Regards
Ian Stuart
PS. Does anyone know the name of that sad little lizard - I think I know him
!

Quote
> Jack wrote...
> Hi, is there a easy way to draw multiple line text in a cell of a
> TStringGrid?
> =============================================
> Jack Wu
> Global Investment Systems
> j...@gisltd.com

Re:How to draw multiple line text in a cell in TStringGrid


Quote
On Wed, 13 Oct 1999 16:17:32 -0400, "Jack Wu" <j...@gisltd.com> wrote:
>Hi, is there a easy way to draw multiple line text in a cell of a
>TStringGrid?
>Thanks.

Download an excellent example made by Wayne Niddery
http://home.ican.net/~wniddery/freedelphistuff.html

HTH
ain

Re:How to draw multiple line text in a cell in TStringGrid


Quote
<Ain Valtin> wrote in message news:3805c762.5239462@forums.inprise.com...
> On Wed, 13 Oct 1999 16:17:32 -0400, "Jack Wu" <j...@gisltd.com> wrote:

> >Hi, is there a easy way to draw multiple line text in a cell of a
> >TStringGrid?

> Download an excellent example made by Wayne Niddery
> http://home.ican.net/~wniddery/freedelphistuff.html

Another excellent example can be found as one of Lou's Tips:
TStringGrid -- Wordwrap
http://members.truepath.com/delphi/tips/tip40_tstringgridwordwrap1.htm

___
efg

Earl F. Glynn     E-Mail:  EarlGl...@att.net
Overland Park, KS  USA

efg's Computer Lab:  http://www.efg2.com/Lab

Other Threads