Solved

Column Alignment Setting in StringGrid

Posted on 2001-08-21
3
554 Views
Last Modified: 2010-04-06
I'd like to set a column alignment in a StringGrid component. Can Anyone tell me how to set it?

ysimon
0
Comment
Question by:ysimon
  • 2
3 Comments
 
LVL 6

Accepted Solution

by:
zebada earned 50 total points
ID: 6411342
I derive a component called TIniGrid from TStringGrid and override the DrawCell method. I also include an array of justification settings called FJustify[] that holds the justification settings for each column.

procedure TIniGrid.DrawCell(ACol, ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  t: string;
  just: UINT;

  begin
  Canvas.Font.Color := Font.Color;
  if ( gdFixed in State ) then
    Canvas.Brush.Color := FixedColor
  else
    if ( gdSelected in State ) then
    begin
      Canvas.Brush.Color := clHighLight;
      Canvas.Font.Color := clHighLightText;
    end
    else
      Canvas.Brush.Color := Color;
  Canvas.FillRect(Rect);

  if ( (ACol<FixedCols) or (ARow<FixedRows) ) then
  begin
    Canvas.Pen.Style := psSolid;
    Canvas.Pen.Color := clBtnShadow;
    Canvas.MoveTo(Rect.Left,Rect.Bottom-1);
    Canvas.LineTo(Rect.Right-1,Rect.Bottom-1);
    Canvas.LineTo(Rect.Right-1,Rect.Top);
    Canvas.Pen.Color := clBtnHighlight;
    Canvas.LineTo(Rect.Left,Rect.Top);
    Canvas.LineTo(Rect.Left,Rect.Bottom-1);
  end;

  t := Cells[ACol,ARow];
  Rect.Top := Rect.Top + 2;
  Rect.Left := Rect.Left + 2;
  Rect.Right := Rect.Right - 4;
  Rect.Bottom := Rect.Bottom - 2;
  case ( FJustify[ACol] ) of
    taLeftJustify:
      just := DT_LEFT;
    taCenter:
      just := DT_CENTER;
    taRightJustify:
      just := DT_RIGHT;
    else
      just := DT_LEFT;
  end;
  DrawText(Canvas.Handle,PChar(t),Length(t),Rect,just);
end;



0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6872397
ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101 or Netminder will return to finalize these if still open in seven days.  Please post closing recommendations before that time.

Question(s) below appears to have been abandoned. Your options are:
 
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you. You must tell the participants why you wish to do this, and allow for Expert response.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question. Again, please comment to advise the other participants why you wish to do this.

For special handling needs, please post a zero point question in the link below and include the question QID/link(s) that it regards.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click the Help Desk link on the left for Member Guidelines, Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Please click you Member Profile to view your question history and keep them all current with updates as the collaboration effort continues, to track all your open and locked questions at this site.  If you are an EE Pro user, use the Power Search option to find them.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.11866558.html
http://www.experts-exchange.com/questions/Q.20107980.html
http://www.experts-exchange.com/questions/Q.20112507.html
http://www.experts-exchange.com/questions/Q.20121203.html
http://www.experts-exchange.com/questions/Q.20122370.html
http://www.experts-exchange.com/questions/Q.20128022.html
http://www.experts-exchange.com/questions/Q.20128024.html
http://www.experts-exchange.com/questions/Q.20143035.html
http://www.experts-exchange.com/questions/Q.20145949.html
http://www.experts-exchange.com/questions/Q.20164917.html
http://www.experts-exchange.com/questions/Q.20164983.html
http://www.experts-exchange.com/questions/Q.20171798.html
http://www.experts-exchange.com/questions/Q.20179154.html
http://www.experts-exchange.com/questions/Q.20192667.html
http://www.experts-exchange.com/questions/Q.20192583.html
http://www.experts-exchange.com/questions/Q.20200806.html
http://www.experts-exchange.com/questions/Q.20201786.html
http://www.experts-exchange.com/questions/Q.20201947.html
http://www.experts-exchange.com/questions/Q.20246959.html
http://www.experts-exchange.com/questions/Q.20252474.html
http://www.experts-exchange.com/questions/Q.20259886.html
http://www.experts-exchange.com/questions/Q.20270462.html
http://www.experts-exchange.com/questions/Q.20273241.html


To view your locked questions, please click the following link(s) and evaluate the proposed answer.
http://www.experts-exchange.com/questions/Q.20265181.html
http://www.experts-exchange.com/questions/Q.20277546.html

PLEASE DO NOT AWARD THE POINTS TO ME.  
 
------------>  EXPERTS:  Please leave any comments regarding your closing recommendations if this item remains inactive another seven (7) days.  Also, if you are interested in the cleanup effort, please click this link http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643
 
Thank you everyone.
 
Moondancer
Moderator @ Experts Exchange

P.S.  For any year 2000 questions, special attention is needed to ensure the first correct response is awarded, since they are not in the comment date order, but rather in Member ID order.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7079716
Zero response from anyone, finalized.
Moondancer - EE Moderator
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Mdi application Child forms get behind control 7 212
find a node in VST 2 68
Delphi IDE crash without error message ... 7 90
Convert MS Word document to a PDF file 9 80
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
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…

773 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