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 determine if ColCount has changed in a TStringGrid 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
127
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Tomas Rutkauskas

I'm writing a TStringGrid descendant in which I would like to know, if the ColCount 
is being changed, because I have some other objects hidden in the component, that 
should be updated, when the ColCount changes. How can I accomplish that?

Answer:

You can try the following:

1   unit MyStringGrid;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Grids;
7   
8   type
9     TMyStringGrid = class(TStringGrid)
10    private
11      FColCount: Integer;
12      FOnColCountChanged: TNotifyEvent;
13      procedure SetColCount(Value: Integer);
14    protected
15      procedure ColCountChanged; virtual;
16    public
17      constructor Create(aOwner: TComponent); override;
18    published
19      property ColCount: Integer read FColCount write SetColCount default 5;
20      property OnColCountChanged: TNotifyEvent read FOnColCountChanged
21        write FOnColCountChanged;
22    end;
23  
24  procedure register;
25  
26  implementation
27  
28  procedure register;
29  begin
30    RegisterComponents('Test', [TMyStringGrid]);
31  end;
32  
33  constructor TMyStringGrid.Create(aOwner: TComponent);
34  begin
35    inherited Create(aOwner);
36    FColCount := 5;
37  end;
38  
39  procedure TMyStringGrid.SetColCount(Value: Integer);
40  begin
41    if FColCount <> Value then
42    begin
43      FColCount := Value;
44      inherited ColCount := FColCount;
45      ColCountChanged;
46    end;
47  end;
48  
49  procedure TMyStringGrid.ColCountChanged;
50  begin
51  
52    {do dependend stuff here}
53  
54    if Assigned(FOnColCountChanged) then
55      FOnColCountChanged(Self);
56  end;
57  
58  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