开发者

Problem with RadioGroup.ControlCount in Delphi 2010

I'd like to set RadioButton properties in runtime in procedure InitRadioGroup(). It fails because RadioGroup.ControlCount is 0, although there are 3 RadioButtons in RadioGroup.

What is wrong in D2010 RadioGroup? Same code works fine in Delphi 2007.

procedure InitRadioGroup(RadioGroup: TRadioGroup);
var
  i: integer;
  RadioButton: TRadioButton;
begin
  for i := 0 to RadioGroup.ControlCount - 1 do
  begin
    RadioButton := (RadioGroup.Controls[i] as TRadi开发者_开发问答oButton);

    RadioButton.ParentColor := False;
    RadioButton.ParentFont  := False;
    RadioButton.Font.Style  := [];
end;


I assume that the RadioGroup is not visible when your procedure is called. So the RadioButtons may not be created then.

A call to RadioGroup.HandleNeeded should fix this for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜