当前位置:网站首页>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;
}
}
}
边栏推荐
- [template] longest common subsequence ([DP or greedy] board)
- How to explain binary search to my sister? This is really difficult, fan!
- On flow delivery between microservices
- 2022 Heilongjiang provincial examination on the writing skills of Application Essays
- BeanUtils -- shallow copy -- example / principle
- Penetrate the remote connection database through the Intranet
- Qt入门-制作一个简易的计算器
- selenium,元素操作以及浏览器操作方法
- Integral link, inertia link and proportion link in Simulink
- P3008 [usaco11jan]roads and planes g (SPFA + SLF optimization)
猜你喜欢

A better database client management tool than Navicat

题解:《压缩技术》(原版、续集版)

The 29 year old programmer in Shanghai was sentenced to 10 months for "deleting the database and running away" on the day of his resignation!

Error: eacces: permission denied, access to "/usr/lib/node_modules"

Selenium installing selenium in pycharm

(POJ - 1984) navigation nightare (weighted and search set)

2022 Heilongjiang provincial examination on the writing skills of Application Essays
![[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术](/img/a7/44609a5acf25021f1fca566c3d8c90.png)
[技术发展-22]:网络与通信技术的应用与发展快速概览-2- 通信技术

Find love for speed in F1 delta time Grand Prix

Whole house Wi Fi: a pain point that no one can solve?
随机推荐
How to explain binary search to my sister? This is really difficult, fan!
使用BLoC 构建 Flutter的页面实例
自定义事件,全局事件总线,消息订阅与发布,$nextTick
Codeforces Round #803 (Div. 2)(A~D)
Qt新项目_MyNotepad++
2022 home projector preferred! Dangbei F5 brings the ultimate audio-visual experience with its powerful audio-visual effect
P1908 reverse sequence pair
Halcon extract orange (Orange)
题解:《你的飞碟在这儿》、《哥德巴赫猜想》
当贝投影4K激光投影X3 Pro获得一致好评:万元投影仪首选
Will your sleep service dream of the extra bookinfo on the service network
selenium的特点
P1042 [noip2003 popularization group] Table Tennis
给Android程序员的一些面试建议「建议收藏」
基于ssm+jsp框架实现的学生选课信息管理系统【源码+数据库】
[document tree, setting] font becomes smaller
Don't spend money, spend an hour to build your own blog website
Add sequence number column to query results in MySQL
Memory management 01 - link script
[deep learning] simple implementation of neural network forward propagation