现在的位置: 首页 > 综合 > 正文

c#打印文本文件简单实例

2012年10月09日 ⁄ 综合 ⁄ 共 7015字 ⁄ 字号 评论关闭

 

实例代码如下:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;
using System.Text;
using System.Drawing.Printing;

namespace PrintDemo
{
    
/// <summary>
    
/// Form1 的摘要说明。
    
/// </summary>

    public class DemoForm : System.Windows.Forms.Form
    
{
        
private System.Windows.Forms.TextBox txtDoc;
        
private System.Windows.Forms.MainMenu mnuMain;
        
private System.Windows.Forms.MenuItem mnuFile;
        
private System.Windows.Forms.MenuItem mnuFileOpen;
        
private System.Windows.Forms.MenuItem mnuFilePrint;
        
private System.Windows.Forms.MenuItem mnuFormat;
        
private System.Windows.Forms.MenuItem mnuFormatFont;
        
private System.Windows.Forms.OpenFileDialog dlgOpen;
        
private System.Windows.Forms.FontDialog dlgFont;
        
private System.Drawing.Printing.PrintDocument pdoc;
        
/// <summary>
        
/// 必需的设计器变量。
        
/// </summary>

        private System.ComponentModel.Container components = null;
        
private System.Windows.Forms.MenuItem mnuFilePrintPreview;
        
private System.Windows.Forms.MenuItem mnuFilePageSetup;
        
private System.Windows.Forms.PrintPreviewDialog ppd;
        
private System.Windows.Forms.PageSetupDialog dlgPageSetup;
        
private System.Windows.Forms.PrintDialog dlgPrinterSetup;
        
private int totalLines;

        
public DemoForm()
        
{
            
//
            
// Windows 窗体设计器支持所必需的
            
//
            InitializeComponent();

            
//
            
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
            
//
        }


        
/// <summary>
        
/// 清理所有正在使用的资源。
        
/// </summary>

        protected override void Dispose( bool disposing )
        
{
            
if( disposing )
            
{
                
if (components != null
                
{
                    components.Dispose();
                }

            }

            
base.Dispose( disposing );
        }


        
Windows 窗体设计器生成的代码

抱歉!评论已关闭.