Board index » delphi » WrapText in DBGrid ?

WrapText in DBGrid ?

Hai,

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

Andy Susanto

 

Re:WrapText in DBGrid ?


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

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

news:3cfaf9f2_1@dnews...
Quote

> Hai,

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

> Andy Susanto

Re:WrapText in DBGrid ?


Hello Quasidata,

can you give me an example ?

--
I would appreciate any help.

Andy Susanto

Quote
Quasidata wrote in message <3cfb0256$1_1@dnews>...
>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" <a...@cpssoft.com> wrote in message
>news:3cfaf9f2_1@dnews...

>> Hai,

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

>> Andy Susanto

Re:WrapText in DBGrid ?


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

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

news:3cfb0f6f_2@dnews...
Quote
> can you give me an example ?

Re:WrapText in DBGrid ?


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

Quote
Quasidata wrote in message <3cfb3ad7_1@dnews>...
>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" <a...@cpssoft.com> wrote in message
>news:3cfb0f6f_2@dnews...
>> can you give me an example ?

Re:WrapText in DBGrid ?


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

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

news:3cfc3689_1@dnews...
Quote
> 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.
> --

Re:WrapText in DBGrid ?


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

Quote
Quasidata wrote in message <3cfc753c$1_1@dnews>...
>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

Re:WrapText in DBGrid ?


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

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

news:3cfde5ce_2@dnews...
Quote
> 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;

Other Threads