Solved

TStringGrid overlapping text

Posted on 2003-11-03
3
267 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
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 170 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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now