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

Reading number is top 10 articles
轻松掌握Ajax.net系列教程七:使用ModalPopupExtender_[Asp.Net教程]
PHP实现定时生成HTML网站首页_php资料_编程技术
ASP.NET开发经验(2):ASP.NET中的一些图形处理_[Asp.Net教程]
组件编程之TypeConverterAttribute_[Asp.Net教程]
Delphi以图形按钮显示的界面
delphi获取Windows目录
C#网络应用编程基础练习题与答案(十)_.net资料_编程技术
delphi程序中动态创建、删除视图
SQL Server备份文件导入当前数据库_[SQL Server教程]
PHP.MVC的模板标签系统之标签行为调度_[PHP教程]
Reading number is top 10 pictures
Sora aoi on twitter5
新版武松打虎
Absolutely shocked. National geographic 50 animal photographys10
Average female college students2
BingBingFan apple dew point photo gallery5
Beautiful vacuum girl1
A man's favorite things4
BingBingFan apple dew point photo gallery2
Fierce chengdu woman, street rape man
Players in the eyes of a perfect love1
Download software ranking
Eclipse 4.2.2 For Win64
WebService在.NET中的实战应用教学视频 → 第3集
Boxer vs Yellow2
好色的外科大夫
Unix video tutorial10
Unix video tutorial11
Jinling thirteen stock
Boxer's Top ten classic battle6
Proficient in JavaScript
matrix1
qq published in(发表于) 2014/7/9 1:39:37 Edit(编辑)
C#中的PageSetupDialog组件的应用实例

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

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

PageSetupDialog组件的应用

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

程序开发步骤如下所示。

(1)在VS 2005中新建一个项目,选择Windows窗体模板,并命名为PageSetupDialog。给窗体添加一个PageSetupDialog组件,然后再添加一个PrintDocument组件。

(2)在窗体中继续添加一个Button按钮,并将按钮的Text属性值设置为“打印”,然后在click事件中添加如下代码:

private void button1_Click(object sender, EventArgs e)

{

pageSetupDialog1.Document = printDocument1;

pageSetupDialog1.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 PageSetupDialog对话框




添加到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.