请教大家:动态创建fastReport报表时,如何定位各位控件位置???急呀

dickman dickman 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
以下是fastReport自带的动态报表demo, 显示了如何动态创建bandView及MemoView,其位置由SetBounds方法设置(其座标相对于整个页面)。 但在实际的应用当中,会有多个bandView、多个MemoView ,如果光在程序中用setbound方法设置各对象位置,将相关麻烦.

能否这样: 先在frReport1中画好几个bandView, 在程序中动态创建MemoView,关其定位在指定的BandView中(设置座标时相对于这个指定的BandView,就象Delphi中Panel里的控件),这样将大大减小工作量,或者各位朋友有什么更多好的方案???

小弟先谢了

procedure TForm1.Button1Click(Sender: TObject);
var
v: TfrView;
b: TfrBandView;
Page: TfrPage;
begin
frReport1.Pages.Clear;
frReport1.Pages.Add; // create page
Page := frReport1.Pages[0];

b := TfrBandView.Create; // create Title band
b.SetBounds(0, 20, 0, 20); // position and size in pixels
b.BandType := btReportTitle; // (only Top and Height are significant
Page.Objects.Add(b); // for the band)

v := TfrMemoView.Create; // create memo
v.SetBounds(20, 20, 200, 16);

v.BandAlign := baWidth;
v.Prop['Alignment'] := frtaCenter; // another way to access properties
v.Prop['Font.Style'] := 2;
v.Memo.Add('Your text is: [Edit1.Text]');
Page.Objects.Add(v);

b := TfrBandView.Create; // create MasterData band
b.SetBounds(0, 60, 0, 20);
b.BandType := btMasterData;
b.Dataset := 'frDBDataSet1'; // band's dataset
Page.Objects.Add(b);

v := TfrMemoView.Create; // create data field
v.SetBounds(20, 60, 200, 16);
v.Memo.Add('[Table1."Company"]');
Page.Objects.Add(v);

frReport1.Pages.Add; // create second page
Page := frReport1.Pages[1];
Page.PageType := ptDialog;
Page.Width := 200;
Page.Height := 170;
Page.Caption := 'Test';

v := TfrEditControl.Create; // create editbox
v.SetBounds(60, 50, 75, 21);
v.Name := 'Edit1';
Page.Objects.Add(v);

v := TfrButtonControl.Create; // create button
v.SetBounds(60, 100, 75, 25);
TfrButtonControl(v).Button.Caption := 'Test!';
TfrButtonControl(v).Button.ModalResult := mrOk;
Page.Objects.Add(v);

frReport1.ShowReport;
end;
...全文

相关推荐

评论 4
收藏 已收藏
分享
返回顶部
dickman
Delphi 5,944 成员 262,941 内容