Solved

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

Posted on 2004-04-21
1
185 Views
Last Modified: 2010-04-05

Hi,

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;
begin
  r := TRadioButton.Create(self);
  if FRadioList.Count = 0 then
    begin
    r.Top := 28;
    r.width := 15;
    end
  else
    begin
    r.Top := TRadioButton(FRadioList[FRadioList.Count-1]).top + 25;
    r.width := 300;
    end;
  r.left := 8;
  r.parent := self;
  r.caption := aCaption;
  r.checked := aValue;
  FRadioList.Add(r);
end;
0
Comment
Question by:dealclickcouk
1 Comment
 
LVL 27

Accepted Solution

by:
kretzschmar earned 50 total points
ID: 10876881
add a onClick event
....
  r.caption := aCaption;
  r.checked := aValue;
  r.onClick := RadioClick;
  FRadioList.Add(r);
....

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

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

meikl ;-)
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

830 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