How to check when a control changes that it is created at runtime

Posted on 2004-04-21
Medium Priority
Last Modified: 2010-04-05


I have the code below which creates a number of radio buttons on the form at runtime, at default none are selected.  I want a procedure that will activate a button if any of the radio buttons are selected, how do I do this?

procedure Tform.CreateRadio(aCaption : String; aValue : Boolean);
var r : TRadioButton;
  r := TRadioButton.Create(self);
  if FRadioList.Count = 0 then
    r.Top := 28;
    r.width := 15;
    r.Top := TRadioButton(FRadioList[FRadioList.Count-1]).top + 25;
    r.width := 300;
  r.left := 8;
  r.parent := self;
  r.caption := aCaption;
  r.checked := aValue;
Question by:dealclickcouk
1 Comment
LVL 27

Accepted Solution

kretzschmar earned 200 total points
ID: 10876881
add a onClick event
  r.caption := aCaption;
  r.checked := aValue;
  r.onClick := RadioClick;

procedure Tform1.RadioClick(Sender : TObject);
var i : integer;
  i := 0;
  while (i < FRadioList.Count) and
          not(TRadioButton(FRadioList[i]).Checked) do inc(i);
  Button1.enabled := i < FRadioList.Count;

just from head,
usual, if a radio is clicked, it will be checked,
so the loop above may obsolete

meikl ;-)

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

621 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