C
CoCo_
Unregistered / Unconfirmed
GUEST, unregistred user!
做一个Label和ComboBox的混合控件,如下:
TCustomControl1 = class(TCustomControl)
private
FLabel:TLabel;
FComboBox:TComboBox;
……
在Create中想设置ComboBox的Items,总是报错:
constructor TCustomControl1.Create(AOwner: Tcomponent);
const Gap=5;
begin
inherited Create(Aowner);
height:=100;
width:=100;
FComboBox:=TComboBox.Create(Self);
FComboBox.left:=Flabel.left+55;
FComboBox.top:=Gap;
FcomboBox.Items.Create;
<font color=red>FcomboBox.Items.Add('所言及是');
FcomboBox.Items.Add('难置可否');
FcomboBox.Items.Add('全非如此');</font>
FComboBox.Parent:=Self;
FComboBox.Visible:=True;
end;
把红色的去掉就不报错了,编译的时候不报错,把控件放到面板里就报错,Why?
TCustomControl1 = class(TCustomControl)
private
FLabel:TLabel;
FComboBox:TComboBox;
……
在Create中想设置ComboBox的Items,总是报错:
constructor TCustomControl1.Create(AOwner: Tcomponent);
const Gap=5;
begin
inherited Create(Aowner);
height:=100;
width:=100;
FComboBox:=TComboBox.Create(Self);
FComboBox.left:=Flabel.left+55;
FComboBox.top:=Gap;
FcomboBox.Items.Create;
<font color=red>FcomboBox.Items.Add('所言及是');
FcomboBox.Items.Add('难置可否');
FcomboBox.Items.Add('全非如此');</font>
FComboBox.Parent:=Self;
FComboBox.Visible:=True;
end;
把红色的去掉就不报错了,编译的时候不报错,把控件放到面板里就报错,Why?