向各位 C++Builder 高手求教:单选按钮不见了!
rchen 2000-05-26 06:13:00 我希望在表单 Form1 上建立一个组合框,框里有两个
单选按钮,并要求组合框和单选按钮都是动态创建的。
为实现这个目的,先建立组合框对象 GroupBox1,单选
按钮 RadioButton1,RadioButton2,然后把 GroupBox1 的
Parent 属性置为 Form1,RadioButton1,RadioButton2的
Parent 属性置为 GroupBox1。代码如下:
然后编译,连接......结果发现 Form1 上只有 GroupBox1,
单选按钮不知所踪! 另外,如果 GroupBox1 不是动态创建,
而是预先拉到表单上的,结果一切正常;如果把
RadioButton2->Parent 改为 Form1, 结果也正常,但组合框
的组合目的却没有达到。
到底怎样才能让单选按钮露面呢,请各位高手救我!
兄弟在这里先作揖了。
void __fastcall TForm1::FormCreate(TObject *Sender)
{
TGroupBox *GroupBox1 = new TGroupBox(this);
TRadioButton *RadioButton1 = new TRadioButton(this);
TRadioButton *RadioButton2 = new TRadioButton(this);
GroupBox1->Parent = Form1;
GroupBox1->Left = 10;
GroupBox1->Top = 100;
GroupBox1->Width = 200;
GroupBox1->Height = 100;
GroupBox1->Caption = "";
RadioButton1->Parent = GroupBox1;
RadioButton1->Left = 11 ;
RadioButton1->Top = 120 ;
RadioButton1->Width = 100;
RadioButton1->Height = 20;
RadioButton1->Caption = "a. 衣带渐宽终不悔";
RadioButton2->Parent = GroupBox1;
RadioButton2->Left = 11 ;
RadioButton2->Top = 180 ;
RadioButton2->Width = 100;
RadioButton2->Height = 20;
RadioButton2->Caption = "b. 为伊消得人憔悴";
}