我想要的是怎么设置printDialog的Document属性 因为它都是空的 该怎么弄才能让它有内容啊
解决方案 »
- 我想给textBox添加一个按键事件,应该怎么加啊
- 字符串求助!
- 怎么判断一个字符串是否是Decimal类型的?
- 如何根据ProcessCmdKey方法的Message参数获取消息源的类型?
- 请问DataTable要如何实现movenext等方法?
- 我用.Net制作的任何安装程序都无法正常安装了.
- winform页面上只有一个textbox如何永久锁定光标在这个textbox上
- web页面默认值的问题
- 怎么可以取到一个路径的最后一个字符串
- 现有一变量strPath="c:\test.xls",要想把它变为@"c:\test.xls"赋给另一个变量,怎么办?
- 未能找到存储过程的问题
- c# 中如何得到指定數據集中某個字段值?
{
printDocument1.PrinterSettings = printDialog1.PrinterSettings;
printDocument1.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings;
printDocument1.DefaultPageSettings.Margins = new Margins(20, 20, 20, 20);
printDocument1.Print();
}
this.printDialog1.Document = this.printDocument1;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Printing;
using System.Drawing.Printing;namespace Test6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
PrintDocument pd = new PrintDocument();
private void Form1_Load(object sender, EventArgs e)
{
//label1.Text = DateTime.Now.ToString();
// timer1.Start();
} private void timer1_Tick(object sender, EventArgs e)
{
// label1.Text = DateTime.Now.ToString();
} private void textBox1_TextChanged(object sender, EventArgs e)
{ } private void button2_Click(object sender, EventArgs e)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
pd.PrintPage += new PrintPageEventHandler(pd1);
ppd.Document = pd;
ppd.ShowDialog();
} private void button1_Click(object sender, EventArgs e)
{
pd.DocumentName = "测试打印机";
//pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
//if(pd.prin)
pd.Print();
} void pd1(object sender, PrintPageEventArgs e)
{
e.Graphics.DrawString(textBox1.Text,new Font("avail",20),Brushes.Red,10,10,new StringFormat());
}