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
Solved

TStringGrid overlapping text

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

838 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