Solved

TStringGrid removal of selected field highlight..

Posted on 1997-08-03
1
172 Views
Last Modified: 2010-04-04
have two or more StringGrids (delphi 1.0), and when I move from  one to
another, the latest accessed cell in the one I left is highlighted. I don´t
want that.
Anyone know how I solve this?
Thanks
Jorgen
0
Comment
Question by:jorgen
1 Comment
 
LVL 3

Accepted Solution

by:
mirek071497 earned 50 total points
ID: 1340398
You must set property DefaultDrawning to false and assign you'r own procedure for OnDrawCell event.

This is example of that.

procedure TForm1.StringGrid1DrawCell(Sender: TObject; Col, Row: Longint;
  Rect: TRect; State: TGridDrawState);

  procedure MyDrawCell( S : TStringGrid );
  var Text: array[0..255] of Char;
  begin
    if (Col<S.FixedCols) or (Row<S.FixedRows) then
      S.Canvas.Brush.Color := S.FixedColor
    else
      S.Canvas.Brush.COlor := S.Color;
    S.Canvas.FillRect(Rect);

    StrPCopy(Text, IntToSTr(col)+'-'+IntToStr(row){StringGrid1.Cells[Col, Row]});
    ExtTextOut(S.Canvas.Handle, Rect.Left + 2, Rect.Top + 2, ETO_CLIPPED or
      ETO_OPAQUE, @Rect, Text, StrLen(Text), nil);

    if S.Ctl3D then
    begin
      S.Canvas.Pen.Color := clBtnHighlight;
      S.Canvas.Polyline([Point(Rect.Left, Rect.Bottom - 1), Rect.TopLeft, Point(Rect.Right, Rect.Top)]);
    end;

    if (S.Row=Row) and (S.Col=Col) and (gdFocused in State) then
      S.Canvas.DrawFocusRect(Rect);

  end;

begin
  if Sender is TStringGrid then
    MyDrawCell( Sender as TStringGrid );
end;

0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Intraweb submit form as a POST request 4 304
Intraweb download file link ? 1 134
Magic Software info 18 131
Delphi problems to abort a printjob 9 20
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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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