Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to make the cell of a TStringGrid flash when its value changes Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
04-Nov-02
Category
VCL-General
Language
Delphi 2.x
Views
87
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I want the cell in a TStringGrid to flash for a few seconds when its value changes 
(as a result of some outside monitored process for example). How would I do that?

Answer:

One way would be to check the contents of the cell against the previous value in 
the OnDrawCell event. When it has changed, start a timer which invalidates the grid 
on a set interval. Below you'll find an example for just one cell.

1   {Somewhere in the private section of the form}
2   var
3     FToggleCount: integer;
4     FCheckstring: string;
5   
6   implementation
7   
8   procedure TForm1.Timer1Timer(Sender: TObject);
9   begin
10    Inc(FToggleCount);
11    if FToggleCount >= 10 then
12      Timer1.Enabled := False;
13    StringGrid1.Invalidate;
14  end;
15  
16  procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
17    Rect: TRect; State: TGridDrawState);
18  var
19    s: string;
20  begin
21    if (ACol = 1) and (ARow = 1) then
22      with Sender as TStringGrid do
23      begin
24        s := Cells[ACol, ARow];
25        if s <> FCheckstring then
26        begin
27          FCheckstring := s;
28          FToggleCount := 0;
29          Timer1.Enabled := True;
30        end;
31        if Timer1.Enabled and ((FToggleCount mod 2) = 0) then
32        begin
33          Canvas.Brush.Color := clRed;
34          Canvas.FillRect(Rect);
35          Canvas.TextOut(Rect.Left + 2, Rect.Top + 2, s);
36        end;
37      end;
38  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC