Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

WrapText in DBGrid ?

1,290 views
Skip to first unread message

Andy Susanto

unread,
Jun 3, 2002, 1:08:39 AM6/3/02
to

Hai,

Can I WrapText in DBGrid like excel ?
--
I would appreciate any help.

Andy Susanto


Quasidata

unread,
Jun 3, 2002, 1:44:29 AM6/3/02
to
Hello Andy,

The issue is that in DBGrid the height of every row is the same. DBGrid
calculates DefaultRowHeight depending on the grid font. To cheat the grid,
set huge font size for the grid to extend row heigt and paint text
yourself in OnDrawColumnCell with normal font using DrawText.

--
Andrei Fomine.
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@once - full-blown clipboard and drag-and-drop transfer in native
MS Office formats to/from any control.
www.quasidata.com


"Andy Susanto" <an...@cpssoft.com> wrote in message
news:3cfaf9f2_1@dnews...

Andy Susanto

unread,
Jun 3, 2002, 2:40:24 AM6/3/02
to
Hello Quasidata,

can you give me an example ?

--
I would appreciate any help.

Andy Susanto
Quasidata wrote in message <3cfb0256$1_1@dnews>...

Quasidata

unread,
Jun 3, 2002, 5:45:37 AM6/3/02
to
Andy,

Download the samples for the Marco Cantů book at
http://www.marcocantu.com/ddh/default.htm
Look for Chapter 17 / GRIDDEMO

--
Andrei Fomine.
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@once - full-blown clipboard and drag-and-drop transfer in native
MS Office formats to/from any control.
www.quasidata.com


"Andy Susanto" <an...@cpssoft.com> wrote in message

news:3cfb0f6f_2@dnews...

Andy Susanto

unread,
Jun 3, 2002, 11:39:33 PM6/3/02
to
Hai Quasidata,

Can you tell me where the mistake in my code:

tblBugSTATUS = The rain in Spain falls mainly on the plain.
DBGrid.Font.Size = 20;

if Column.Field = tblBugSTATUS then begin
DBGrid1.Canvas.Font.Size := 8;
DBGrid1.Canvas.TextOut(Rect.Left,Rect.Top,
WrapText(tblBugSTATUS.AsString, #13#10, ['.',' ',#9,'-'], 42) );
end;

and the result that I get in that column about two text something like this:
The rain in Spain falls mainly on the plain. <<<< font size = 8
The rain in Spain falls mainly on the plain. <<<< font size =20

i want that text like this:
The rain in Spain falls mainly on the
plain.


--
I would appreciate any help.

Andy Susanto
Quasidata wrote in message <3cfb3ad7_1@dnews>...

Quasidata

unread,
Jun 4, 2002, 4:07:00 AM6/4/02
to
Hello Andy,

Add DBGrid1.Canvas.FillRect(Rect); to clear the cell.

--
Andrei Fomine.
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@once - full-blown clipboard and drag-and-drop transfer in native
MS Office formats to/from any control.
www.quasidata.com


"Andy Susanto" <an...@cpssoft.com> wrote in message

news:3cfc3689_1@dnews...

Andy Susanto

unread,
Jun 5, 2002, 6:19:35 AM6/5/02
to
Hai Quasidata,

I add the syntax that you said DBGrid1.Canvas.FillRect(Rect); and the
result that i got a blank in Column status. If i put FillRect(Rect)
outside if statement my all Columng in DBGrid turn blank. What should I do
now ?

if Column.Field = tblBugHistSTATUS then begin
DBGrid1.Canvas.Font.Size := 8;
DBGrid1.Canvas.TextOut(Rect.Left,Rect.Top,
WrapText(tblBugHistSTATUS.AsString, #13#10, ['.',' ',#9,'-'], 10) );
DBGrid1.Canvas.FillRect(Rect);
end;


--
I would appreciate any help.

Andy Susanto

Quasidata wrote in message <3cfc753c$1_1@dnews>...

Quasidata

unread,
Jun 5, 2002, 7:07:58 AM6/5/02
to
Hello Andy,

Move it one line heigher. Write text using Windows.DrawText instead of
Canvas.TextOut.

--
Andrei Fomine.
DbAltGrid - multi-line layout, RTF and graphics of any kind in DBGrid.
Transfer@once - full-blown clipboard and drag-and-drop transfer in native
MS Office formats to/from any control.
www.quasidata.com

"Andy Susanto" <an...@cpssoft.com> wrote in message

news:3cfde5ce_2@dnews...

0 new messages