Solved

TStringGrid removal of selected field highlight..

Posted on 1997-08-03
1
174 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
select query - oracle 16 100
how to update exe applicatio from internet ? 6 87
firemonkey keyboard covers the controls 1 37
DBCtrlGrid, Delphi, Scroll 7 26
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…
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 …
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 …

808 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