📄 20010417001.htm
字号:
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeTitle->Left = PreLeft +
_arrayFieldType[i].iWidth;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeTitle->Top = 0;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeTitle->Width= 1;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>if( i == pDBGrid->FieldCount-1) //最后一列的分隔竖条宽度为0</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeTitle->Width= 0;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td
class=a14>_arrayFieldType[i].pShapeTitle->Height=_arrayFieldType[i].pShapeTitle->Parent->Height;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>//显示的数据栏</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText= new TQRDBText(pQuickRep);
//该字段对应的文本控件</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Parent = DetailBand1;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->DataSet = pDataSet; //数据集</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->DataField = pDBGrid->Columns->Items[i]->FieldName;
//字段名</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Font = pDBGrid->Columns->Items[i]->Font;
//字体</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Alignment= pDBGrid->Columns->Items[i]->Alignment;
//对齐方式</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Left = PreLeft+_iIntClearance;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Width = _arrayFieldType[i].iWidth-2*_iIntClearance;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Height= _arrayFieldType[i].pDBText->Font->Height;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pDBText->Top=</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td
class=a14>pDetailRect->Top+(pDetailRect->Height+_arrayFieldType[i].pDBText->Height)/2;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeData= new TQRShape(pQuickRep);
//该数据右边的分隔竖条</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeData->Parent= DetailBand1;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeData->Left = PreLeft+_arrayFieldType[i].iWidth;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeData->Top = 0;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeData->Width= 1;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>if( i== pDBGrid->FieldCount-1) //最后一列的分隔竖条宽度为0</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>_arrayFieldType[i].pShapeData->Width= 0;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td
class=a14>_arrayFieldType[i].pShapeData->Height=_arrayFieldType[i].pShapeData->Parent->Height;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>PreLeft= _arrayFieldType[i].pShapeTitle->Left; //下列字段的左位置</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>}</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>}</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>TGridPrint::~TGridPrint() //析构函数</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>{ delete pTitleLabel; delete pHeadRect; delete pDetailRect;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>for(int i=0; i< pDBGrid->FieldCount;i++)</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>{ delete _arrayFieldType[i].pDBText; delete _arrayFieldType[i].pShapeData;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>delete _arrayFieldType[i].pLabel; delete _arrayFieldType[i].pShapeTitle;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>} }</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>void TGridPrint::DoPreview() //打印预览函数</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>{ pQuickRep->Preview(); }</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14><i>2.2 定制报表</i></td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td
class=a14>类的公共接口提供有4个函数SetPrntTitle、SetColumnsWidth、SetHeadRectHeight、SetDetailRectHeight,分别是手工设置表格的总标题、表格各列宽度、字段标题行的高度和数据行的高度。编程人员可自己设计相关界面,供用户来对报表的布局做进一步的修正,满足用户的要求,提高了报表的质量和用户参与的积极性。实际上,这样做将编程人员在报表设计阶段的工作转交给用户来做,避免了原来设计好不能改变的问题。</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14><i>2.3 调用方法</i></td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td
class=a14>完成类TGridPrint的设计后,编程人员可以在需要的地方很方便地调用它。调用前注意包含两个头文件。调用时,需将下面构造函数里的DBGrid1换成程序界面上实际使用的TDBGrid控件名字,其它不用改动。</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>#include "GridPrint.h"</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>#include "RepRst.h"</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>TFrmRepRst *pFrmRepRst= new TFrmRepRst(NULL);</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>TGridPrint *pGridPrint= new TGridPrint(pFrmRepRst->QuickRep1,
DBGrid1, pFrmRepRst->TitleBand1, pFrmRepRst->ColumnHeaderBand1,
pFrmRepRst->DetailBand1);</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>pGridPrint->DoPreview(); </td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14>delete pGridPrint; delete pFrmRepRst;</td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td class=a14><b>3.结束语</b></td>
</tr>
</tbody>
</table>
<table align=center width=620>
<tbody>
<tr>
<td
class=a14>在前人设计的基础上,根据任务的需要,采用面向对象的设计方法,可设计出实现目标的新类,并能被继承和扩充。本文只针对数据表格TDBGrid控件设计的,起抛砖引玉的作用,读者可在上述思路的基础上,针对其它格式的报表,进行自动生成报表的设计。</td>
</tr>
</tbody>
</table>
<br>
</td>
</tr>
</table>
</div>
</BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -