| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1021 人关注过本帖
标题:[分享][求助]打印窗体与一打印设置问题
只看楼主 加入收藏
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
 问题点数:0 回复次数:15 
[分享][求助]打印窗体与一打印设置问题

以下是打印窗体的源码(下面还用了窗体按数据量自动变形---上下)
因打出的分辩率是默认的,效果不太好,请问要改分辩率.......语句是怎么写...谢大家了
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
namespace huixinERP
{
public partial class Print_SH : Form
{
public Print_SH()
{
InitializeComponent();
}

private void Print_Load(object sender, EventArgs e)
{
string sql11 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\My Documents\\huixinERP\\obj\\Release\\data\\path.mdb";
string selec11 = "SELECT 路径 from LJ";
OleDbConnection conn11 = new OleDbConnection(sql11);
OleDbDataAdapter dataa11 = new OleDbDataAdapter(selec11, conn11);
conn11.Open();
DataSet dataset21 = new DataSet();
dataa11.Fill(dataset21, "LJ");
conn11.Close();
path.DataBindings.Add("Text", dataset21, "LJ.路径");
string sql = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\\My Documents\\huixinERP\\obj\\Release\\data\\path.mdb";
string sele = "SELECT * from Prints";
string sele1 = "SELECT 施工单号,印件名称,起止号码,单价,数量,提货单 from Prints";
string sele2 = "SELECT 施工单号,印件名称,起止号码,单价,数量 from Prints";
OleDbConnection conn = new OleDbConnection(sql);
OleDbDataAdapter dataa = new OleDbDataAdapter(sele, conn);
OleDbDataAdapter dataa1 = new OleDbDataAdapter(sele1, conn);
OleDbDataAdapter dataa2 = new OleDbDataAdapter(sele2, conn);
DataSet dataset1 = new DataSet();
DataSet dataset2 = new DataSet();
DataSet dataset3 = new DataSet();
conn.Open();
dataa.Fill(dataset1, "Prints");
dataa1.Fill(dataset2, "Prints");
dataa2.Fill(dataset3,"Prints");
dataGrid1.SetDataBinding(dataset3, "Prints");
conn.Close();
dataGrid1.RowHeadersVisible = false;
dataGrid1.CaptionVisible = false;
DWMC.DataBindings.Clear();
GDH.DataBindings.Clear();
RQs.DataBindings.Clear();
DWMC.DataBindings.Add("Text", dataset1, "Prints.单位名称");
GDH.DataBindings.Add("Text", dataset1, "Prints.提货单");
RQs.DataBindings.Add("Text", dataset1, "Prints.日期");
int a=Convert.ToInt32(dataset1.Tables["Prints"].Rows.Count.ToString());
if (a > 1)
{
a = (a - 1) *23;
int b = label13.Location.X;
int c = label13.Location.Y;
c += a;
Point poin = new Point(b, c);
label13.Location = poin;
b= label14.Location.X ;
c = label14.Location.Y;
c += a;
Point poin1 = new Point(b, c);
label14.Location = poin1;
b = label7.Location.X;
c = label7.Location.Y;
c += a;
Point poin2 = new Point(b, c);
label7.Location = poin2;
b = label8.Location.X;
c = label8.Location.Y;
c += a;
Point poin3 = new Point(b, c);
label8.Location = poin3;
int z = dataGrid1.Size.Height;
int y = dataGrid1.Size.Width;
z += a;
System.Drawing.Size siz = new Size(y,z);
this.dataGrid1.Size = siz;
int s =ClientSize.Height;
int w = ClientSize.Width;
s += a;
System.Drawing.Size siz1 = new Size(w, s);
this.ClientSize = siz1;
int r = Prin.Location.X;
int t = Prin.Location.Y;
t += a;
Point poins = new Point(r, t);
Prin.Location = poins;
}
}
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern long BitBlt(IntPtr hdcDest, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);
private Bitmap memoryImage;
private void CaptureScreen()
{
Graphics mygraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, mygraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
IntPtr dc1 = mygraphics.GetHdc();
IntPtr dc2 = memoryGraphics.GetHdc();
BitBlt(dc2, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height, dc1, 0, 0, 13369376);
mygraphics.ReleaseHdc(dc1);
memoryGraphics.ReleaseHdc(dc2);
}
private void Prin_Click(object sender, EventArgs e)
{
Prin.Visible = false;
string sql1 = path.Text;
string sele = "UPDATE THBH SET 提货单号=" + Convert.ToInt32(Convert.ToInt32(GDH.Text) + 1);
OleDbConnection conn1 = new OleDbConnection(sql1);
conn1.Open();
OleDbCommand comm = new OleDbCommand(sele, conn1);
comm.ExecuteNonQuery();
conn1.Close();
CaptureScreen();
printDocument1.Print();
}

private void printDocument1_PrintPage_1(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
}
}

搜索更多相关主题的帖子: 窗体 打印 分享 设置 
2007-03-24 11:32
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
得分:0 

高手再哪..自已顶一个


2007-03-24 13:45
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
得分:0 
顶顶顶..

2007-03-26 08:34
liuminghui
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:2882
专家分:0
注 册:2007-1-26
收藏
得分:0 
不错啊!!就是不知道什么时候用窗体的打印功能呢?

帮你顶顶!

海鸽 is My Lover!!
2007-03-26 09:38
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
得分:0 
再顶

2007-03-26 11:56
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
得分:0 
顶顶顶.....累了..

2007-03-26 12:47
jacklee
Rank: 7Rank: 7Rank: 7
来 自:XAplus
等 级:贵宾
威 望:32
帖 子:1769
专家分:104
注 册:2006-11-3
收藏
得分:0 
拷屏+打印

XAplus!
讨论群:51090447
删吧删吧,把我的号给删了!
2007-03-26 12:50
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
得分:0 

嗯.不过..我现在想要的是改变分辩率的设置..怎么写??


2007-03-26 13:47
lunly
Rank: 1
等 级:新手上路
帖 子:295
专家分:0
注 册:2007-1-17
收藏
得分:0 
再顶一个

2007-03-28 08:45
jacklee
Rank: 7Rank: 7Rank: 7
来 自:XAplus
等 级:贵宾
威 望:32
帖 子:1769
专家分:104
注 册:2006-11-3
收藏
得分:0 
啥意思?改变显示器的分辨率?

XAplus!
讨论群:51090447
删吧删吧,把我的号给删了!
2007-03-28 08:59
快速回复:[分享][求助]打印窗体与一打印设置问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.026764 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved