当前位置:网站首页>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;
}
}
}
边栏推荐
猜你喜欢
[document tree, setting] font becomes smaller

SystemServer进程

BeanUtils -- shallow copy -- example / principle

Selenium, element operation and browser operation methods

rxjs Observable 自定义 Operator 的开发技巧
![[Blue Bridge Cup] children's worship circle](/img/ad/5af4fe76ad5d1426bc460904d7f049.jpg)
[Blue Bridge Cup] children's worship circle

Qt-制作一个简单的计算器-实现四则运算-将结果以对话框的形式弹出来

In 2021, the global TCB adapter revenue was about $93 million, and it is expected to reach $315.5 million in 2028

uniapp小程序 subPackages分包配置

千元投影小明Q1 Pro和极米NEW Play谁更好?和哈趣K1比哪款配置更高?
随机推荐
2022 Heilongjiang provincial examination on the writing skills of Application Essays
给Android程序员的一些面试建议「建议收藏」
Qt-制作一个简单的计算器-实现四则运算
Everyone believes that the one-stop credit platform makes the credit scenario "useful"
D language, possible 'string plug-ins'
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
不会看器件手册的工程师不是个好厨子
Word frequency statistics & sorting
【文档树、设置】字体变小
MySQL 45 lecture - learning the actual battle of MySQL in Geek time 45 Lecture Notes - 05 | easy to understand index (Part 2)
Winter vacation daily question - lucky numbers in the matrix
MySQL -- convert rownum in Oracle to MySQL
无主灯设计:如何让智能照明更加「智能」?
Selenium, element operation and browser operation methods
数据湖(十一):Iceberg表数据组织与查询
MySQL45讲——学习极客时间MySQL实战45讲笔记—— 05 | 深入浅出索引(下)
OpenFOAM:lduMatrix&lduAddressing
Explanation: here is your UFO, Goldbach conjecture
Whole house Wi Fi: a pain point that no one can solve?
题解《子数整数》、《欢乐地跳》、《开灯》