Solved

Controlling properties of created components

Posted on 1997-08-22
1
168 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
[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
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

Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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