我的一点看法如下,摘自我的报表设计器原码,使用的是C++Builder,请原谅了。此程序仅供参考,具体的细节自己体会了。
void __fastcall TReport:: InitBands(void)
{
if(FPageRoot==NULL)ErrorBreak();//you can not care this line
for(int i=bsCanvas;i<=bsSummary;i++)
InitBand((TBandStyle)i);
}
void __fastcall TReport:: InitBand(TBandStyle Style)
{
PBand Value;
Value = new TBand;
if(Value == NULL)ErrorBreak();
Value->Style = Style;
Value->Color = Style;
Value->Rect.Left,Top,Height,Width = 0,0,30,0;
//节省一点空间,各位见谅
Value->Frame.Color,DrawBottom,DrawLeft,DrawRight,DrawTop,Style,Width=clBlack,false,false,false,false,PS_SOLID,1;
int AWidth,alen;
switch(Style)
{
case bsCanvas:
{
AWidth = FPageRoot->Rect.Width;
alen = ConversionUnit(FMargin.Unit,puPixes,FMargin.Left.Value);
Value->Rect.Left = alen;
AWidth -= alen;
alen = ConversionUnit(FMargin.Unit,puPixes,FMargin.Right.Value);
AWidth -= alen;
Value->Rect.Width = AWidth;
AWidth = FPageRoot->Rect.Height;
alen = ConversionUnit(FMargin.Unit,puPixes,FMargin.Top.Value);
Value->Rect.Top = alen;
AWidth -= alen;
alen = ConversionUnit(FMargin.Unit,puPixes,FMargin.Bottom.Value);
AWidt-= alen;
Value->Rect.Height = AWidth;
break;
}
default:
{
TRegionRect Rrect = FList[Style-1]->Value->Rect;
Value->Rect = Rrect;
if(Style!=bsTitle)
Value->Rect.Top = Rrect.Top + Rrect.Height;
Value->Rect.Height = 40;
break;
}
}
InsertTree(rsBand,Value);//将它插入你的属性列表中效果一样的
Value = NULL;
delete Value;
}
//小弟的动态报表设计器不久也完成了,现在都能测试了,一起努力吧,有什么问题一起探讨一下。