Solved

Adjusting row height for a DBMemo

Posted on 2000-05-03
4
547 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

705 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