Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

TStringGrid overlapping text

Posted on 2003-11-03
3
Medium Priority
?
279 Views
Last Modified: 2010-04-05
Hi I've got a text output from one of my Oracle procedures that looks like this:

RECno.      Pageid      Pagerpid      Subjid      Blid      lborres_repl      low      high      unit      factor      Calc res.
________________________________________________________________________________
15      0110            1001      0020      2338      0      1000      U/L      1      2338
Message:
"SGOT/AST" (2338 U/L) is outside plausibility range (0 - 1000 U/L) and clinically acceptable.
------------------------------------------------------------------------------------------------------------------------
16      0110            1001      0020      2229      0      1000      U/L      1      2229
Message:
"SGPT/ALT" (2229 U/L) is outside plausibility range (0 - 1000 U/L) and clinically acceptable.
------------------------------------------------------------------------------------------------------------------------
96      0180            1002      0080      1156      0      1000      U/L      1      1156
Message:
"SGPT/ALT" (1156 U/L) is outside plausibility range (0 - 1000 U/L) and clinically acceptable.
------------------------------------------------------------------------------------------------------------------------
222      0140            1005      0060      0.3      30      250      umol/L      88.4      26.52
Message:
"Serum Creatinine" (0,3 mg/dL) is outside plausibility range (0.34 - 2.83 mg/dL) and clinically acceptable.
------------------------------------------------------------------------------------------------------------------------


For a better readability i want to put it in a TStringGrid, but now the message gets cut after the width of the 1st column.

What would be the best aproach?

Thx in advance
Robert
0
Comment
Question by:GeorgeWNewbie
[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
3 Comments
 
LVL 2

Expert Comment

by:Robn
ID: 9671498
use a TDrawGrid.
When you draw a row with your message, invalidate all the cells in that row, paint your text, and be sure not to FillRect the remaining columns for that row on their paint message or you will wipe out the text. Kinda messy though.
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 680 total points
ID: 9673630
From Peter Below's snippets:

Draw merged cells on a stringgrid

procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
var
  i, x, y: Integer;
begin
  If gdFixed In State Then Exit;
  If ARow > 1 Then Exit;

  // draw row 1 with text from cell 1,1 spanning all cells in the row
  with sender as tstringgrid do begin
    {extend rect to include grid line on right, if not last cell
     in row}
    If aCol < Pred(ColCount) Then
      Rect.Right := Rect.Right + GridlineWidth;

    {figure out where the text of the first cell would start relative
     to the current cells rect. }
    y:= Rect.Top + 2;
    x:= Rect.Left + 2;
    for i:= 1 to aCol-1 do
      x:= x - ColWidths[i] - GridlineWidth;

    { Paint cell pale yellow}
    Canvas.Brush.Color := $7FFFFF;
    Canvas.Brush.Style := bsSolid;
    Canvas.FillRect( Rect );

    { Paint text of cell 1,1 clipped to current cell. }
    Canvas.TextRect( Rect, x, y, Cells[1,1] );
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i, k: Integer;
begin
  with stringgrid1 do begin
    cells[1, 1] := 'A rather long line which will span cells';
    for i:= 1 to colcount-1 do
      for k:= 2 to rowcount -1 do
        cells[i,k] := Format( 'Cell[%d,%d]',[i,k]);
  end;
end;

0
 

Author Comment

by:GeorgeWNewbie
ID: 9678933

Thanks a lot.

I only had to change 4 lines and it worked.
0

Featured Post

Independent Software Vendors: 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

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 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