Solved

TStringGrid overlapping text

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

9 Experts available now in Live!

Get 1:1 Help Now