Solved

Controlling properties of created components

Posted on 1997-08-22
1
153 Views
Last Modified: 2013-11-23
Greetings,

I am a GUI/RAD beginner with knowledge of  OOP. I am writing a class that contains a TStringGrid component. In the constructor of that class, I create the object. Now, how do I create events for that component, if I cannot 'see' it at design time, so that the method pointer can be initialized? (Also, is it an acceptable practice to include VCL components inside of classes?) I currently have to include the component on the form, and in the constructor, I assign that instance to the class's declared one. This works fine, allowing me to assign events, but this seems  cumbersome. All comments are welcome! Thankyou.
0
Comment
Question by:Edo082297
1 Comment
 
LVL 4

Accepted Solution

by:
StevenB earned 60 total points
ID: 1342203
 Creating event handlers for the TStringGrid is pretty easy:

  Your components create procedure should include something like this:

  AGrid := TStringGrid.Create(AOwner);
  AGrid.Parent := AOwner;
  AGrid.OnClick := AGridClick // The Important line

  Then Simply define the AGridClick procedure as you would for any other event handler.

  From your question, I think this is the information you're after, however if you were actually asking how to declare new events, rather than handlers for existing events, then that's slightly more lengthy. I'll explain this procedure if you need, but I'm a bit short of time now. Leave a comment if you want more advice.

  As far as I'm concerned it's acceptable behavior to include VCL components within your own components, however I appreciate your concern. I always feal ever so slightly awkward about doing it. That said, I've been doing it for some time now and it's never caused any problems, so I reckon it's OK.

  Steven.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi 2010 Export to pdf 2 287
Wininet read php file from internet issue 6 82
How to fill array with TArray.Create? 14 79
Working this component WebCopy with proxy, help 3 76
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

15 Experts available now in Live!

Get 1:1 Help Now