Solved

TStringGrid removal of selected field highlight..

Posted on 1997-08-03
1
170 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
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 85
Firewall issues 6 85
calling procedure inside activexForm from secondform 1 206
code issue 8 84
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now