当前位置:网站首页>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;
}
}
}
边栏推荐
猜你喜欢

Will your sleep service dream of the extra bookinfo on the service network

Don't spend money, spend an hour to build your own blog website

2022 Heilongjiang provincial examination on the writing skills of Application Essays

Daily practice of C language --- monkeys divide peaches

In 2021, the global revenue of structural bolts was about $796.4 million, and it is expected to reach $1097.6 million in 2028

c# 水晶报表打印

Subcontracting configuration of uniapp applet subpackages

使用BLoC 构建 Flutter的页面实例
[document tree, setting] font becomes smaller

Design of non main lamp: how to make intelligent lighting more "intelligent"?
随机推荐
题解《子数整数》、《欢乐地跳》、《开灯》
P1908 逆序对
错误:EACCES:权限被拒绝,访问“/usr/lib/node_modules”
自定义事件,全局事件总线,消息订阅与发布,$nextTick
[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术
I did it with two lines of code. As a result, my sister had a more ingenious way
selenium的特点
Selenium element positioning method
Origin plots thermogravimetric TG and differential thermogravimetric DTG curves
题解:《你的飞碟在这儿》、《哥德巴赫猜想》
刚好1000粉丝,记录一下
ArrayList and LinkedList
Stone merging Board [interval DP] (ordinary stone Merging & Ring Stone merging)
Integral link, inertia link and proportion link in Simulink
A better database client management tool than Navicat
Halcon extract orange (Orange)
BeanUtils--浅拷贝--实例/原理
你的 Sleep 服务会梦到服务网格外的 bookinfo 吗
Achievements in science and Technology (27)
Qt-制作一个简单的计算器-实现四则运算-将结果以对话框的形式弹出来