Solved

OnClick event doesn't work

Posted on 1998-08-23
3
338 Views
Last Modified: 2010-04-04
when I place a TButton on TStringGrid like this:

Button1.Parent:=StringGrid1;

then, the OnClick Event of the Button doesn't work.
With SpeedButtons it works fine.
Any ideas?
0
Comment
Question by:ronit051397
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 50 total points
ID: 1337474
Hi,
This is a simple solution. You could inherit the TButton and add the ControlStyle line to the decendant constructor if you want:

procedure TForm1.MyButtonClick(Sender: TObject);
begin
  ShowMessage( 'I work!' );
end;

procedure TForm1.FormCreate(Sender: TObject);
  ...
  with TButton.Create( Self ) do begin
    ControlStyle := ControlStyle + [csClickEvents]; // add this!
    Parent := StringGrid1;
    with StringGrid1.CellRect( 1, 1 ) do SetBounds( Left, Top, Right - Left + 1, Bottom - Top + 1 );
    Caption := 'My button';
    OnClick := MyButtonClick;
  end;
end;

/// John
0
 
LVL 5

Author Comment

by:ronit051397
ID: 1337475
Thanks.
Do you know why this is working with TPanel but not working with TStringGrid?
0
 
LVL 5

Author Comment

by:ronit051397
ID: 1337476
For some reason, this is not working with TUpDown Component. Do you know why?
0

Featured Post

Technology Partners: 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

Title # Comments Views Activity
Tembedded WB animatid gifs not animated on some pcs 2 85
DBGrid or StringGrid ? 6 119
Delphi problems to abort a printjob 9 34
Delphi android app hide keyboard 3 40
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…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

713 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