Solved

Adjusting row height for a DBMemo

Posted on 2000-05-03
4
536 Views
Last Modified: 2010-04-04
Hi

I have a DBGrid which contains a DBMemo field, and I have overridden  DrawColumnCell to show the text in the field.

I want to be able to adjust the RowHeight up or down for each record so that all the text in that field is showing for an individual record.

I have looked at GetTextMetrics but I cannot get anything to work.  Can someone please provide a code snippet to show me what to do.

Thanks in advance

John
0
Comment
Question by:jdthedj
  • 2
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ronvp
ID: 2791644
Well, you may want to give this hack a try:

With TStringGrid(DBGrid1) do
   RowHeights[Row] := 50;

You will still have to do some work to handle scrolling and other redraws correctly but this will set the individual rowheight.

You may also Visit Torries website or the Delphi Super Page to browse for free DBGrids with this allready implemented.

By far the best way though is to (and I am not commercially linked) obtain a copy of the ExpressQuantumGrid of Developer Express. http://www.devexpress.com/ You will get this and a ton of other features..


0
 
LVL 3

Author Comment

by:jdthedj
ID: 2797457
Hi Ronvp - thanks for the reply.

I have tried putting your code into the DrawColumnCell method. It works (sort of) - the problem is the grid keeps on trying to repaint itself so it flickers all the time and I cannot edit it's data or read it all.

Any ideas?

John
0
 
LVL 1

Accepted Solution

by:
ronvp earned 100 total points
ID: 2799260
What is happening is that wnhen you adjust your rowheight, you will cause a recursion to the DrawColumnCell event. What you need to do adjust your code so that it will first check if the Rowheight needs to be adjusted and then execute the code. this will stop the recursion

Here is a (Non tested) example based on the DrawColumnCell event handler

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
  DataCol: Integer; Column: TColumn; State: TGridDrawState);
Begin
With TStringGrid(DBGrid1) do
  If (Column.Field.FieldName = 'my field name') and
     (RowHeights[Row] <> 50)
  then
     RowHeights[Row] := 50;
end;

Just replace my field name with the field name that you need (must be a exact match)
0
 
LVL 3

Author Comment

by:jdthedj
ID: 2801959
Thanks Ronvp - that is exactly what I need.

John
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now