关于Parent问题
我想将一个窗体上的控件的Parent改为加外一个窗体上的Panel
不知道为什么不行?
总是提示have no parent???
代码如下:
function AssnGoods(GoodsNo:String;GoodsRecord:TGoodsRecord;X,Y:Integer;Parent,CurCtrl,NextCtrl:TWinControl):Boolean;
var
ssql:String;
li:TListItem;
begin
Result:=False;
with frmzxgPublicUnit do
begin
Fx:=X;
Fy:=Y;
FFlag:='goods';
FGoodsInfo:=@GoodsRecord;
FParent:=Parent;
FCurCtrl:=CurCtrl;
FNextCtrl:=NextCtrl;
lvAssn.Columns[0].Caption:='商品编码';
lvAssn.Columns[1].Caption:='商品名称';
lvAssn.Parent:=Parent;
//设置ListView的位置
{if X+lvAssn.Width>Parent.ClientWidth then
lvAssn.Left:=Parent.ClientWidth-lvAssn.Width
else}
lvAssn.Left:=X;
{if Y+lvAssn.Height>Parent.ClientHeight then
lvAssn.Top:=Parent.ClientHeight-lvAssn.Height
else}
lvAssn.Top:=Y;
//
lvAssn.Items.Clear;
ssql:='select * from jxc_Spda where f_Jb='+IntToStr(FJB)+
' and f_bm like '''+GoodsNo+'%''';
with adsAssn do
begin
Close;
CommandText:=ssql;
Open;
if not IsEmpty then
if RecordCount=1 then
if FieldByName('f_mj').AsInteger=1 then
begin
with GoodsRecord do
begin
f_Bm:=FieldByName('f_Bm').AsString;
f_Mc:=FieldByName('f_Mc').AsString;
f_Hh:=FieldByName('f_Hh').AsString;
f_Spcd:=FieldByName('f_Spcd').AsString;
f_Ggxh:=FieldByName('f_Ggxh').AsString;
f_Spsl:=FieldByName('f_Spsl').AsString;
f_Jldw1:=FieldByName('f_Jldw1').AsString;
f_Jldw2:=FieldByName('f_Jldw2').AsString;
f_Dwbl2:=FieldByName('f_Dwbl2').AsFloat;
f_Pcgl:=FieldByName('f_Pcgl').AsString;
f_Cbhsfs:=FieldByName('f_Cbhsfs').AsString;
f_Jb:=FieldByName('f_Jb').AsInteger;
f_Mj:=FieldByName('f_Mj').AsInteger;
f_Zhjj:=FieldByName('f_Zhjj').AsFloat;
f_Qssj:=FieldByName('f_Qssj').AsFloat;
end; //with GoodsRecord
FJb:=1;
lvAssn.Visible:=False;
NextCtrl.SetFocus;
Exit;
end //if FieldByName('f_Mj')
else
begin
while not Eof do
begin
li:=lvAssn.Items.Add;
li.Caption:=FieldByName('f_bm').AsString;
li.SubItems.Add(FieldByName('f_Mc').AsString);
Next;
end; //wihle
end;
end; //with adsAssn
lvAssn.Visible:=True;
lvAssn.SetFocus; //就在这个地方提示"have no parent??
lvAssn.Items[0].Selected:=True;
lvAssn.Items[0].Focused:=True;
end; //with frmzxgPublicUnit
end;
请各们大侠指教!!
我在线恭候!!!!!!!!!!!!