Jump to content


Photo

DBGrid Individual RowHeight to show komplete Memo

dbGrid rowHeight

  • Please log in to reply
1 reply to this topic

#1 Ulrich Schaupp

Ulrich Schaupp
  • Members
  • 7 posts

Posted 11 August 2023 - 09:29 AM

Hello Boki,

 

how can I calc rowheight in dbGrid to show the complete table column text or Memo in associated grid cell?

 

Best regards

Uli



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,212 posts
  • Gender:Male

Posted 31 August 2023 - 09:32 PM

Hello Uli,
 
Please excuse me for delay.
 
For this purpose you can use OnMeasureRowHeight event. In this event you will read Index parameter and then you can set var parameter RowHeight.
procedure TForm2.NextDBGrid61MeasureRowHeight(Sender: TObject; Index: Integer; var RowHeight: Integer);
begin
  if Index = 2 then RowHeight := 40;
end;
Inside it we can use for example GetTextSize that I have in NxGraphics6.pas unit. Or you can use TCanvas.TextRect to measure text size.

For example:

procedure TForm2.NextDBGrid61MeasureRowHeight(Sender: TObject; Index: Integer; var RowHeight: Integer);
begin
  RowHeight := GetTextSize(NextDBGrid61.Canvas, MyRectToFit, NxDBTextColumn61.DataBinding.Field.AsInteger).cy;
end;
I hope that this helps. If not I can make a small demo.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users