急救:动态生成的pplabel显示不出来????(100分)

  • 主题发起人 cddelphi
  • 开始时间
C

cddelphi

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在打印报表时动态生成ppLabel和ppDBText,然后给它们赋值。我查找了动态
生成控件的资料,我写了如下代码:
var gj: array of TppLabel;
//动态添加显示国家名称的TppLabel
setlength(gi,m);
for i := 0 to m-1do
begin
gj := TppLabel.Create(self);
gj.Caption :=trim(country);
//给它赋值
end;
//为动态生成的TppLabel控件指定位置
i:=0;
gj.Top :=50;
gj.Left :=100;
gj.Height :=50;
gj.Width :=50;
gj.AutoSize :=true;
gj.Visible :=true;
gj.Font.Size :=12;
gj.Font.Charset :=GB2312_CHARSET;
gj.Font.Color :=clBlack;
gj.Font.Height := -16;
gj.Font.Name :='宋体';
gj.Font.Pitch :=fpDefault;
结果打印时没有显示出来,我想可能是没有加上parent,于是我加上了:
gj.parent:=self;(或form1之类的)
但编译时提示:can not assign to a read-only property,该怎样才能让动态生成的
TppLable显示出来呢?
急用,谢谢!
 
将parent放在visible属性之前试试?
 
如果是在集成环境中你的gj[]加在了什么地方A,
gj.parent := A。
比如在QuickReport你应加在QRBand1上
例如在QuickReport中,你应该这样做:
for I := 0 to 3do
begin
S := TQRLabel.Create(Self);
S.Parent := QRBand1;
S.Caption := IntToStr(I);
S.Top := 12;
S.Left := I * 40;
end;
 
好象是report builder不允许设置parent,一给parent赋值就说:can not assign to a read
only property.
 
你的信我收到了,也回了,很对不起的就是,我没用过report builder
 
我已经在你的另一贴中回了。
不是设Parent而是Band
如: S.Band := yourReport.HeaderBand;
 
to DJ;
我试过了,我加了gj.band:=ppreport1.headerband,但还是看不见呀!
 
因为很难上来,所以来晚了。
谢谢大家,特别感谢DJ,后来我用了一个笨办法暂时解决了,我先放了几个label,然后赋值的。
这个办法只能不太好,肯定还要找更好的办法的。不过,先把分给了吧。
 
多人接受答案了。
 
我也有同样问题,怀疑Qreport本身有缺陷。
 
顶部