⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 c#版自动升级代码,2005编写的c#版自动升级代码,2005编写的c#版自动升级代码,2005编写的
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using Microsoft.Win32;
using CrystalDecisions.Shared;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void button1_Click(object sender, EventArgs e)
        {
            Test test = new Test();
            Tests tests = new Tests();
            test.Name = this.textBox1.Text;

            test.TotalMenoy = 2.347M;
            tests.Add(test);
            Print(tests, 5, 0, 5, 0);
        }

        private void Print(Tests PrintToFPs, int Left, int Right, int Top, int Bottom)
        {
            ReportDocument Document = new ReportDocument();

            //读取安装路径
            string Path = Environment.CurrentDirectory;

            //Path = Path.Substring(0, Path.Length - 11);

            Path = Path + @"\CrystalReport1.rpt";

            Document.Load(Path);

            Document.SetDataSource(PrintToFPs);

            //ReportDocument SubDocument = Document.Subreports["InvoiceDetail.rpt"];
            
            //SubDocument.SetDataSource(PrintHospitalCharges);

            PageMargins pageMargins = Document.PrintOptions.PageMargins;

            pageMargins.leftMargin = Left;

            pageMargins.rightMargin = Right;

            pageMargins.topMargin = Top;

            pageMargins.bottomMargin = Bottom;

            Document.PrintOptions.ApplyPageMargins(pageMargins);

            try
            {
                Document.PrintToPrinter(10,false, 0, 0);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -