Solved

Adjusting row height for a DBMemo

Posted on 2000-05-03
4
544 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

860 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