Solved

Adjusting row height for a DBMemo

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

696 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