Solved

Adjusting row height for a DBMemo

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi custom sort exception 6 137
Delphi XE10 Round Image 2 79
how to send memory stream from ics Client To ics server ? 11 83
TEMBEDDEDWB how can i change its user agent ? 8 50
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…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

20 Experts available now in Live!

Get 1:1 Help Now