All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
gridview字段文字超指定字数后显示..._[Asp.Net教程]
C#中创建用户控件应用实例
PHP+MYSQL实例:网站在线人数的程序代码_php资料_编程技术
WM5.0模拟器用AS来使用PC机的网络_.net资料_编程技术
数据库菜鸟不可不看,简单SQL语句小结_mssql学习_编程技术
C#中的多媒体技术:文字处理
PHP建设论坛:Discuz!论坛快速架设指南_php资料_编程技术
初谈ADO.NET中利用DataAdapter进行数据操作_[Asp.Net教程]
从各种位置截取字符串的SQL语法_[SQL Server教程]
Visual,Studio,2008,Professional,简体中文RTM版,体验(1)_[Asp.Net教程]
Reading number is top 10 pictures
来几张有特色的图片
Soldier saw beauty after the reaction
再发两张抽象画
赵惟依写真1
The Soviet union swimsuit exposure in the 70 year1
关于海盗的研究2
mythology hero1
网络游戏与脑残
中国女孩大胆自拍,显露完美身材4
漂亮的跳舞妹妹1
Download software ranking
打鸟视频
卡丁车单机版
虚拟机5.5.3版
天龙八部十二宫服务端
WebService在.NET中的实战应用教学视频 → 第4集
Unix video tutorial17
Detective task-the top secret prostitution files
Ashlynn Video4
Unix video tutorial6
WebService在.NET中的实战应用教学视频 → 第3集
qq published in(发表于) 2014/7/9 1:39:39 Edit(编辑)
C#中的PrintDialog组件的应用实例

C#中的PrintDialog组件的应用实例

C#中的PrintDialog组件的应用实例

PrintDialog组件的应用

下面通过一个例子来说明PrintDialog组件的用法。

程序开发步骤如下所示。

(1)打开上一节的项目,继续在Windows窗体上添加一个PrintDialog组件。

(2)双击窗体中的按钮,在双击事件中添加如下代码:

private void button1_Click(object sender, EventArgs e)

{

pageSetupDialog1.Document = printDocument1;

pageSetupDialog1.ShowDialog();

printDialog1.Document = printDocument1;

printDialog1.ShowDialog();

}

程序运行结果如图1所示。

完整程序代码如下:

★ ★★★★Form1.cs窗体代码文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace PageSetupDialog

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)

{

//pageSetupDialog1.Document = printDocument1;

//pageSetupDialog1.ShowDialog();

printDialog1.Document = printDocument1;

printDialog1.ShowDialog();

}

}

}

★ ★★★★Form1.designer.cs窗体设计文件完整程序代码★★★★★

namespace PageSetupDialog

{

partial class Form1

{

///



/// 必需的设计器变量。

///


private System.ComponentModel.IContainer components = null;

///

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

///


/// 如果应释放托管资源,为 true;否则为 false。

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要

/// 使用代码编辑器修改此方法的内容。

///


private void InitializeComponent()

{

this.pageSetupDialog1 = new System.Windows.Forms.PageSetupDialog();

this.printDocument1 = new System.Drawing.Printing.PrintDocument();

this.button1 = new System.Windows.Forms.Button();

this.printDialog1 = new System.Windows.Forms.PrintDialog();

this.SuspendLayout();

//

// button1

//

this.button1.Location = new System.Drawing.Point(185, 258);

this.button1.Name = "button1";

this.button1.Size = new System.Drawing.Size(75, 23);

this.button1.TabIndex = 0;

this.button1.Text = "打印";

this.button1.UseVisualStyleBackColor = true;

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// printDialog1

//

this.printDialog1.UseEXDialog = true;

//

// Form1

//

this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);

this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

this.ClientSize = new System.Drawing.Size(463, 373);

this.Controls.Add(this.button1);

this.Name = "Form1";

this.Text = "Form1";

this.ResumeLayout(false);

}

#endregion

private System.Windows.Forms.PageSetupDialog pageSetupDialog1;

private System.Drawing.Printing.PrintDocument printDocument1;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.PrintDialog printDialog1;

}

}

★ ★★★★Program.cs主程序文件完整程序代码★★★★★

using System;

using System.Collections.Generic;

using System.Windows.Forms;

namespace PageSetupDialog

{

static class Program

{

///

/// 应用程序的主入口点。

///


[STAThread]

static void Main()

{

Application.EnableVisualStyles();

Application.SetCompatibleTextRenderingDefault(false);

Application.Run(new Form1());

}

}

}



图1 PrintDialog对话框




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.