⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 20010417001.htm

📁 C++Builder教学大全
💻 HTM
📖 第 1 页 / 共 3 页
字号:
          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeTitle-&gt;Left = PreLeft + 

              _arrayFieldType[i].iWidth;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeTitle-&gt;Top = 0;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeTitle-&gt;Width= 1;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>if( i == pDBGrid-&gt;FieldCount-1) //最后一列的分隔竖条宽度为0</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeTitle-&gt;Width= 0;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td 

      class=a14>_arrayFieldType[i].pShapeTitle-&gt;Height=_arrayFieldType[i].pShapeTitle-&gt;Parent-&gt;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-&gt;Parent = DetailBand1;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;DataSet = pDataSet; //数据集</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;DataField = pDBGrid-&gt;Columns-&gt;Items[i]-&gt;FieldName; 

              //字段名</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;Font = pDBGrid-&gt;Columns-&gt;Items[i]-&gt;Font; 

              //字体</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;Alignment= pDBGrid-&gt;Columns-&gt;Items[i]-&gt;Alignment; 

              //对齐方式</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;Left = PreLeft+_iIntClearance;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;Width = _arrayFieldType[i].iWidth-2*_iIntClearance;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;Height= _arrayFieldType[i].pDBText-&gt;Font-&gt;Height;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pDBText-&gt;Top=</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td 

      class=a14>pDetailRect-&gt;Top+(pDetailRect-&gt;Height+_arrayFieldType[i].pDBText-&gt;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-&gt;Parent= DetailBand1;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeData-&gt;Left = PreLeft+_arrayFieldType[i].iWidth;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeData-&gt;Top = 0;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeData-&gt;Width= 1;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>if( i== pDBGrid-&gt;FieldCount-1) //最后一列的分隔竖条宽度为0</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>_arrayFieldType[i].pShapeData-&gt;Width= 0;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td 

      class=a14>_arrayFieldType[i].pShapeData-&gt;Height=_arrayFieldType[i].pShapeData-&gt;Parent-&gt;Height;</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>PreLeft= _arrayFieldType[i].pShapeTitle-&gt;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&lt; pDBGrid-&gt;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-&gt;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-&gt;QuickRep1, 

              DBGrid1, pFrmRepRst-&gt;TitleBand1, pFrmRepRst-&gt;ColumnHeaderBand1, 

              pFrmRepRst-&gt;DetailBand1);</td>

          </tr>

          </tbody>

        </table>

        <table align=center width=620>

          <tbody> 

          <tr> 

            <td class=a14>pGridPrint-&gt;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 + -