当前位置:网站首页>C crystal report printing
C crystal report printing
2022-07-02 14:03:00 【coder i++】
turn :https://www.cnblogs.com/aitong/p/10717786.html
Introduction to crystal report
Crystal report yes vs A report control comes with earlier versions .vs2017 Do not bring your own crystal report , Self installation required . Although the crystal report is a charging control , But Microsoft has already paid , therefore vs The self-contained crystal report can be used directly .
If the project is .net 4.0 Above version , Need modification App.config file . Because of crystal report .net The version may be lower than .net 4.0
When the software is released, the corresponding config Documents released together , Otherwise, crystal report cannot be used
<startup useLegacyV2RuntimeActivationPolicy="true"> // Add useLegacyV2RuntimeActivationPolicy="true"
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
Add datasets in Solution Explorer DataSet1.xsd, Add DataTable.
newly build Crystal Reports file
Create a new... In solution explorer Crystal Reports file : CrystalReport1.rpt . After adding, the left side will appear “ Field Explorer ” . If you accidentally close the field Explorer , Can be in “ View ” “ Other windows ” “ document outline ” Call it out .
vs Corresponding controls will also appear in the toolbox of . You can add text objects to the report . Common attributes of text objects :CanGrow ( Can wrap lines automatically ) HorAlignment ( In the middle , Keep to the left , Keep right ).
Right click the database field and select database expert . Add DataTable1
stay “ Group name field ” Right click to insert Group . choice DataTable1 In the field , The sorting method is selected in the original order ( The sorting method of crystal report is not practical , It's usually set DataTable When sorting ).
In the database field Name Sex You can drag it to the details of the report . The header of the report will automatically add a text box . The content of the text box can be modified to name , Gender .
Add display controls in the interface :CrystalReportViewer Rename it to crv
Create a report object in the window and add data , According to the CrystalReportViewer above . Can print directly , You can also print through the print button on the control .
using CrystalDecisions.CrystalReports.Engine;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CrTest
{
public partial class Form1 : Form
{
public Form1(bool directPrint = false)
{
InitializeComponent();
DataSet1 ds = new DataSet1();
ds.DataTable1.Rows.Add(" Group 1", " Zhang 1", " male ");
ds.DataTable1.Rows.Add(" Group 3", " king 1", " male ");
ds.DataTable1.Rows.Add(" Group 2", " Li 1", " male ");
ds.DataTable1.Rows.Add(" Group 1", " Zhang 2", " male ");
ds.DataTable1.Rows.Add(" Group 1", " Zhang 3", " Woman ");
ds.DataTable1.Rows.Add(" Group 1", " Zhang 4", " male ");
ds.DataTable1.Rows.Add(" Group 2", " Li 2", " male ");
ds.DataTable1.Rows.Add(" Group 2", " Li 3", " Woman ");
ds.DataTable1.Rows.Add(" Group 2", " Li 4", " male ");
ds.DataTable1.Rows.Add(" Group 3", " king 2", " male ");
ReportClass cr = new CrystalReport1();
cr.SetDataSource(ds);
TextObject title = (TextObject)cr.ReportDefinition.ReportObjects["Text1"];
title.Text = " Personnel form ";
if (directPrint)
{
PrintDialog print = new PrintDialog();
if (print.ShowDialog() == DialogResult.OK)
{
cr.PrintOptions.PrinterName = print.PrinterSettings.PrinterName;
cr.PrintToPrinter(1, false, 0, 0);
}
}
this.crv.ReportSource = cr;
}
}
}
边栏推荐
- BeanUtils -- shallow copy -- example / principle
- Astro learning notes
- OpenFOAM:lduMatrix&lduAddressing
- Error: eacces: permission denied, access to "/usr/lib/node_modules"
- Qt-制作一个简单的计算器-实现四则运算
- Data consistency between redis and database
- [template] longest common subsequence ([DP or greedy] board)
- 联合搜索:搜索中的所有需求
- 自定义事件,全局事件总线,消息订阅与发布,$nextTick
- Drawing Nyquist diagram with MATLAB
猜你喜欢
Node. JS accessing PostgreSQL database through ODBC
Design of non main lamp: how to make intelligent lighting more "intelligent"?
MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
[technology development-22]: rapid overview of the application and development of network and communication technology-2-communication Technology
Getting started with QT - making a simple calculator
[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术
uniapp小程序 subPackages分包配置
Everyone believes that the one-stop credit platform makes the credit scenario "useful"
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 05 | 深入浅出索引(下)
你的 Sleep 服务会梦到服务网格外的 bookinfo 吗
随机推荐
P1908 reverse sequence pair
How to set QT manual layout
Don't spend money, spend an hour to build your own blog website
大家信夫一站式信用平台让信用场景“用起来
How to use SAP's metadata framework (MDF) to build custom business rules?
Which do you choose between Alibaba P7 with an annual salary of 900000 and deputy department level cadres?
P3008 [USACO11JAN]Roads and Planes G (SPFA + SLF优化)
P1347 sorting (topology + SPFA judgment ring or topology [inner judgment ring])
题解《子数整数》、《欢乐地跳》、《开灯》
selenium,元素操作以及浏览器操作方法
D how to check null
刚好1000粉丝,记录一下
你的 Sleep 服务会梦到服务网格外的 bookinfo 吗
How to explain binary search to my sister? This is really difficult, fan!
Use bloc to build a page instance of shutter
When tidb meets Flink: tidb efficiently enters the lake "new play" | tilaker team interview
Characteristics of selenium
Pointer from entry to advanced (1)
Selenium element positioning method
Find love for speed in F1 delta time Grand Prix