Solved

Controlling properties of created components

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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