要在 Windows 窗体上显示报表,请添加 CrystalReportViewer 控件。
在“设计”视图中打开 Form1。
从“工具箱”中,打开“生成报表”节点,找到“CrystalReportViewer”控件。
注意在以前版本的 Crystal Reports for Visual Studio 中,CrystalReportViewer 控件出现在“Crystal Reports”节点中。
将“CrystalReportViewer”控件拖放到窗体上。
CrystalReportViewer 控件在控件的右上角显示一个名为“智能任务”面板的新 GUI 功能。
<table>
<colgroup>
<col style="width: 100%" />
</colgroup>
<thead>
<tr class="header">
<th><img src="images/8yfdxzdx.alert_note(zh-cn,VS.90).gif" alt="Note" class="note" />注意</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><p>这是随 ASP.NET 2.0 版一起提供的精简代码开发模型的一部分。CrystalReportViewer 控件的“智能任务”面板使用 GUI 设置简化了诸如报表绑定和控件布局等功能的配置。由于当前使用的是基于代码的开发面板,因此在此设置过程中不会使用智能任务面板。</p></td>
</tr>
</tbody>
</table>
如果智能任务面板处于打开状态,单击“CrystalReportViewer”控件右上角的切换箭头来关闭智能任务面板。
单击 CrystalReportViewer 控件,将其选中。
从“属性”窗口中,设置“Name”属性:
- 对于 Visual Basic Windows 项目,将“Name”属性设置为 myCrystalReportViewer。
- 对于 C# Windows 项目,将“Name”属性设置为 crystalReportViewer。
从“文件”菜单中,单击“全部保存”。
从“生成”菜单中,单击“生成解决方案”。