Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

TStringGrid overlapping text

Posted on 2003-11-03
3
Medium Priority
?
284 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 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

772 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