最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
C#] 打印出不断长大的文字
时间:2022-06-25 04:26:28 编辑:袖梨 来源:一聚教程网
using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.printing;
namespace printtest3
{
public partial class form1 : form
{
public form1()
{
initializecomponent();
}
private void button1_click(object sender, eventargs e)
{
printdocument pd = new printdocument();
//设置边距
//margins margin = new margins(20, 20, 20, 20);
//pd.defaultpagesettings.margins=margin;
pd.printpage += pd_printpage;
pd.print();
}
private void pd_printpage(object sender, printpageeventargs e)
{
for (int i = 0; i < 10; i++)
{
//动态获取字符的高度
sizef string_size = e.graphics.measurestring("第{0}行", new font("宋体", 12+i));
e.graphics.drawstring
(
string.format("第{0}行", i), new font("宋体", 12 + i),
brushes.black, 100, 100 + string_size.height*i
);
}
}
}
}
相关文章
- 沙石镇时光失窃案任务怎么做-详细方法介绍 05-12
- 英雄无敌5亡灵技能怎么选择 05-12
- 攻城掠地建邺怎么打 05-12
- 少年三国志54到60怎么升级 05-12
- 攻城掠地79副本怎么过 05-12
- 影之刃2哪些职业比较强 05-12