请教各位高手。。。

jixiancai 2003-07-28 02:34:57
请教各位高手:
本人使用Visual Studio C#.net实现打印时的页面设置功能
1.当使用如下语句设置页面尺寸时,就会出错,因为Kind属性是只读的
printDocument1.DefaultPageSettings.PaperSize.Kind =PaperKind.B5;
请问如何将页面尺寸设置成B5或者其它纸型?

2.当使用PageSetupDialog类显示和获取用户的页面设置参数时,请问
如何将对话框中的默认纸型大小改为B5或者其它纸型(而不是A4)?

3.printDocument1.PrinterSettings.DefaultPageSettings.PaperSize与
printDocument1.DefaultPageSettings.PaperSize有何区别?
更改纸型大小时两者是否都需要进行设置?

谢谢各位!!!
...全文
35 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
雪狼1234567 2003-07-28
  • 打赏
  • 举报
回复
看看这个,是否有帮助,
private void DrawAll(Graphics g)
{
// Create an alignment object that aligns text to the right side
// for calculations
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Far;

// Force autoscroll to start printing from the origin
this.AutoScrollPosition = new Point(0,0);

// Set up a source rectangle based on the image size
RectangleF srcRect = new Rectangle(0, 0, pictureBox1.Image.Width, pictureBox1.Image.Height);

// Set up a destination rectangle based on the paper size
int nWidth = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Width;
int nHeight = printDocument1.PrinterSettings.DefaultPageSettings.PaperSize.Height;
RectangleF destRect = new Rectangle(0, 0, nWidth, nHeight);

// Draw the bitmap of the blank 1040EZ form
g.DrawImage(HiResImage, destRect, srcRect, GraphicsUnit.Pixel);

// Calculate the scale of the image against the paper so we
// can correctly place the text on top of the image from the
// controls.
float scalex = destRect.Width/srcRect.Width;
float scaley = destRect.Height/srcRect.Height;

// Cycle through each control and draw its contents
foreach (Control c in Controls)
{
// Determine the control type
string strType = c.GetType().ToString().Substring(c.GetType().ToString().LastIndexOf(".") + 1);
if (strType == "TextBox")
{
TextBox theText = (TextBox)c;

// check the alignment of the TextBox. If the Alignment is
// Right Aligned, calculated the Layout Rectangle and draw
// the text right aligned inside the Rectangle
if (theText.TextAlign.ToString() == "Left")
g.DrawString(theText.Text, theText.Font, Brushes.Black, theText.Bounds.Left*scalex, theText.Bounds.Top * scaley,
new StringFormat());
else
{
RectangleF LayoutRect = new RectangleF(theText.Bounds.Left*scalex, theText.Bounds.Top*scaley,
theText.Bounds.Width*scalex, theText.Bounds.Height*scaley);

g.DrawString(theText.Text, theText.Font, Brushes.Black, LayoutRect, sf);
}

}

// if the control is a checkbox and checked, draw an x inside
if (strType == "CheckBox")
{
CheckBox theCheck = (CheckBox)c;
Rectangle aRect = theCheck.Bounds;
if (theCheck.Checked)
{
g.DrawString("x", theCheck.Font, Brushes.Black,
theCheck.Left*scalex + 1, theCheck.Top*scaley + 1, new StringFormat());
}
}

} // end foreach control

}
炎热的夏季已经过去,家乡想必也要开始落叶了。如果我是小学生,让我以《秋》为题目作文,开头一定是“秋天是收获的季节”。是的,经过了春天的骚动,夏季的彷徨,来到了秋。这是新生报到的季节,动物贮藏食物的季节,马上就到十一长假的季节,这个季节更是收获的季节。 我们在播种时,势必首先考虑收成。种庄稼如此,学习语言更是如此。于是,“语言之争”是各个编程论坛必定讨论的话题,很多甚至是“X经”话题。对此,我的观点是:语言没有好坏之分,只有顺手不顺手和你能发挥到什么程度的问题。我们没有必要追求最新,“最先进”的编程方式,只需要学习好力所能及的语言。 VC的无所不能缺点是繁杂,稍有不慎就不知道什么地方出了包;VB常常被人耻笑过于简单,发布之后要带上一个“仓库”;Delphi虽然有快速开发的优势,但却姥姥不疼舅舅不爱的日渐西山…… 其实对于大多数人来说,我们使用什么应该是需求决定而不是语言本身决定需求,比如:我们希望自动根据数据生成表格,没有必要非用Delphi VC 调用 COM ,我们用用VBA就好了。因此,眼中只有那三种基本结构:判断 循环 跳转就差不多了,再高级一点,弄清楚什么是面向对象面向过程,随便一门语言都不会逃出这点东西。 我很佩服俄罗斯的软件,他们就是将语言工具发挥到极致的例子。比如:我在网上搜索到DOS下硬盘速度测试软件,竟然是Pascal编写的。 至于“学习好力所能及的语言”,我的意思是如果你身边有C语言的高手不妨向他请教或者同他切磋;如果你有学好数据结构的理想,不妨买一本Java描述数据结构的图书慢慢啃;如果你有网络数据库+界面的需求不妨考虑一下Delphi…… 因此,我的观点就是“语言没有好坏之分”,关键是你能掌握到什么程度。 当然,如果你能掌握汇编语言,这一切就更不在话下了。我很希望各位能够将学习语言当作乐趣,我们的杂志也将会以如何让读者在阅读中感到快乐感到成就感为目的。

111,112

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧