Solved

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

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

13 Experts available now in Live!

Get 1:1 Help Now