?
Solved

OnClick event doesn't work

Posted on 1998-08-23
3
Medium Priority
?
344 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
[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
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
erajoj earned 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

719 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