Form1.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace PrintPreviewRichTextBox
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
// print command implemented using RichTextBoxDocument class
void printToolStripButton_Click(object sender, EventArgs e)
{
// create document
var doc = new RichTextBoxDocument(richTextBox1);
// set document header and footer
// use '[page]' to get the current page number in headers and footers
// use '[pages]' to get the page count in headers and footers
doc.Header = string.Format("\t - 新益康打印控件测试 - \r\n** {0} **", richTextBox1.Name);
doc.Footer = string.Format("{0}\t{1}\t页数 [page] of [pages]",
DateTime.Today.ToShortDateString(),
DateTime.Now.ToShortTimeString());
// preview the document
//using (var dlg = new PrintPreviewDialog()) // also works, but not as nice...
using (var dlg = new CoolPrintPreview.CoolPrintPreviewDialog())
{
dlg.Document = doc;
dlg.ShowDialog(this);
}
}
// simple implementation of standard file commands (new, open, save)
void newToolStripButton_Click(object sender, EventArgs e)
{
richTextBox1.Clear();
}
void openToolStripButton_Click(object sender, EventArgs e)
{
using (var dlg = new OpenFileDialog())
{
dlg.DefaultExt = ".rtf";
if (dlg.ShowDialog() == DialogResult.OK)
{
try
{
richTextBox1.LoadFile(dlg.FileName);
}
catch (Exception x)
{
MessageBox.Show(x.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
后面还有 51 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
