Solved

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

Posted on 2004-04-21
1
184 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 220
How to call a form that is in a DLL  from an application? 13 74
Printing problem 2 96
Sending files from  idTcpServer Socket to idTcpClient 2 40
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

831 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