当前位置:网站首页>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;
}
}
}
边栏推荐
- 【虹科技术分享】如何测试 DNS 服务器:DNS 性能和响应时间测试
- 你的 Sleep 服务会梦到服务网格外的 bookinfo 吗
- Daily practice of C language --- monkeys divide peaches
- 千元投影小明Q1 Pro和极米NEW Play谁更好?和哈趣K1比哪款配置更高?
- How to use SAP's metadata framework (MDF) to build custom business rules?
- Pointer from entry to advanced (1)
- How to set QT manual layout
- [technology development-22]: rapid overview of the application and development of network and communication technology-2-communication Technology
- MySQL 45 lecture - learning from the actual battle of geek time MySQL 45 Lecture Notes - 04 | easy to understand index (Part 1)
- 自定义事件,全局事件总线,消息订阅与发布,$nextTick
猜你喜欢
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 05 | 深入浅出索引(下)
QT - make a simple calculator - realize four operations
[document tree, setting] font becomes smaller
Subcontracting configuration of uniapp applet subpackages
Error function ERF
混沌工程平台 ChaosBlade-Box 新版重磅发布
selenium 元素定位方法
Halcon extract orange (Orange)
Design of non main lamp: how to make intelligent lighting more "intelligent"?
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
随机推荐
Browser driven Download
In 2021, the global styrene butadiene styrene (SBS) revenue was about $3722.7 million, and it is expected to reach $5679.6 million in 2028
693. 行程排序(map + 拓扑)
In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028
题解《子数整数》、《欢乐地跳》、《开灯》
The global special paper revenue in 2021 was about $27 million, and it is expected to reach $35 million in 2028. From 2022 to 2028, the CAGR was 3.8%
OpenFOAM:lduMatrix&lduAddressing
[document tree, setting] font becomes smaller
Selenium, element operation and browser operation methods
Multi rotor aircraft control using PID and LQR controllers
Just 1000 fans, record it
三谈exception——错误处理
基于ssm+jsp框架实现的学生选课信息管理系统【源码+数据库】
Qt新项目_MyNotepad++
P1042 [NOIP2003 普及组] 乒乓球
[template] longest common subsequence ([DP or greedy] board)
The xftp connection Haikang camera reported an error: the SFTP subsystem application has been rejected. Please ensure that the SFTP subsystem settings of the SSH connection are valid
Selenium element positioning method
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
Common options of tcpdump command: Three