Solved

TStringGrid removal of selected field highlight..

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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

728 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