Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 99
Delphi : could not find program, '...exe' 2 147
Printing problem 2 80
Tviruailstringtree sort multi columns on header click 1 53
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

22 Experts available now in Live!

Get 1:1 Help Now