Delphi 2010中RadioGroup.ControlCount的问题 [英] Problem with RadioGroup.ControlCount in Delphi 2010

查看:131
本文介绍了Delphi 2010中RadioGroup.ControlCount的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在运行时通过InitRadioGroup()过程设置RadioButton属性。
它失败,因为RadioGroup.ControlCount为0,尽管RadioGroup中有3个RadioButton。



D2010 RadioGroup有什么问题?
相同的代码在Delphi 2007中可以正常工作。

 过程InitRadioGroup(RadioGroup:TRadioGroup); 
var
i:整数;
RadioButton:TRadioButton;
for i:= 0到RadioGroup.ControlCount开始
-1做
Begin
RadioButton:=(RadioGroup.Controls [i]作为TRadioButton);

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


解决方案

我假设在您的手术过程中RadioGroup不可见叫做。因此,可能不会再创建RadioButtons。



调用 RadioGroup.HandleNeeded 应该可以为您解决这个问题。 / p>

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 TRadioButton);

    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.

这篇关于Delphi 2010中RadioGroup.ControlCount的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆