Solved

TStringGrid removal of selected field highlight..

Posted on 1997-08-03
1
175 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
[X]
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
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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