原文 Graphics.DrawString 方法

在指定位置并且用指定的 BrushFont 对象绘制指定的文本字符串。

public void DrawString(
string s,
Font font,
Brush brush,
float x,
float y
) MSDN上的实例:
public void DrawStringFloat(PaintEventArgs e)

{

// Create string to draw

. String drawString = "Sample Text"; // Create font and brush.

Font drawFont = new Font("Arial", 16);

 SolidBrush drawBrush = new SolidBrush(Color.Black);// Create point for upper-left corner of drawing.

 float x = 150.0F; float y = 150.0F;// Draw string to screen.

e.Graphics.DrawString(drawString, drawFont, drawBrush, x, y);

}

应用的实例:
          private void Myprintpage1(Graphics formGraphics, int w, int h)
{ Pen myPen = new Pen(Color.FromArgb(255, Color.Black), 1.0F);
Font MyFont1 = new Font("宋体", 12, FontStyle.Bold);
Font MyFont2 = new Font("宋体", 10, FontStyle.Bold); formGraphics.TranslateTransform(100.0F, 50.0F);
//画表格横线 //画表格竖线 for (int i = 200; i < 360; i += 50)
{
formGraphics.DrawLine(myPen, new Point(0, i), new Point(600, i));
formGraphics.DrawLine(myPen,)
} for (int i = 0; i < 750; i += 150)
{
formGraphics.DrawLine(myPen, new Point(i, 200), new Point(i, 350));
} //画表格斜线
formGraphics.DrawLine(myPen, new Point(0, 200), new Point(150, 250));
//formGraphics.DrawLine(myPen, new Point(150, 125), new Point(300, 125));
//formGraphics.DrawLine(myPen, new Point(150, 175), new Point(300, 175));
//写字
formGraphics.DrawString(" ---数据报表---", new Font("宋体", 20, FontStyle.Bold), Brushes.DimGray, 100, -10); formGraphics.DrawString("试验日期(Date) :_______________", MyFont1, Brushes.DimGray, 0, 50);
formGraphics.DrawString("操作人员(Operator):_______________", MyFont1, Brushes.DimGray, 0, 75); formGraphics.DrawString("试件类型(Parts Type):_______________", MyFont1, Brushes.DimGray, 330, 50);
formGraphics.DrawString("试件编号(Parts No):_______________", MyFont1, Brushes.DimGray, 330, 75); formGraphics.DrawString("上号(UP):_______________", MyFont1, Brushes.DimGray, 0, 100);
formGraphics.DrawString("下号(DOWN):_______________", MyFont1, Brushes.DimGray, 330, 100); formGraphics.DrawString("电压", MyFont1, Brushes.DimGray, 190, 220); //formGraphics.DrawString(" (Forward Speed)", MyFont2, Brushes.DimGray, 300, 110);
formGraphics.DrawString("电流", MyFont1, Brushes.DimGray, 340, 220); // formGraphics.DrawString(" (Backward Speed)", MyFont2, Brushes.DimGray, 455, 110);
formGraphics.DrawString("备用", MyFont1, Brushes.DimGray, 490, 220); formGraphics.DrawString("试验数据(Date)", MyFont1, Brushes.DimGray, 0, 270);
formGraphics.DrawString("数据单位(Unit)", MyFont1, Brushes.DimGray, 0, 320); formGraphics.DrawString("操作人员(Operator):_______________ 检验者(Checker):_______________", MyFont1, Brushes.DimGray, 0, 970); formGraphics.DrawString(DateTime.Now.ToString("yyyy/MM/dd"), MyFont1, Brushes.DimGray, 180, 50);
formGraphics.DrawString(global.temstr[0], MyFont1, Brushes.DimGray, 180, 75);
formGraphics.DrawString(global.temstr[2], MyFont1, Brushes.DimGray, 510, 50);
formGraphics.DrawString(global.temstr[1], MyFont1, Brushes.DimGray, 510, 75); formGraphics.DrawString(global.temstr[3], MyFont1, Brushes.DimGray, 180, 100);
formGraphics.DrawString(global.temstr[4], MyFont1, Brushes.DimGray, 500, 100); formGraphics.DrawString(" ", MyFont1, Brushes.DimGray, 190, 270);//
formGraphics.DrawString(" ", MyFont1, Brushes.DimGray, 340, 270);//
formGraphics.DrawString(" ", MyFont1, Brushes.DimGray, 490, 270); formGraphics.DrawString("V", MyFont1, Brushes.DimGray, 190, 320); formGraphics.DrawString("A", MyFont1, Brushes.DimGray, 340, 320); formGraphics.DrawString(" ", MyFont1, Brushes.DimGray, 490, 320); }

												

最新文章

  1. 关于 window.parent, window.top, window.self 详解
  2. presto的动态化应用(一):presto节点的横向扩展与伸缩
  3. NGUI 灰化按钮或图标
  4. Excel 使用CHIINV函数和GAMMA.DIST函数绘制卡方分布
  5. 【Java】嵌套For循环性能优化案例
  6. Oracle临时表
  7. Zabbix discoverer processes more than 75% busy
  8. asp.net mvc4使用百度ueditor编辑器
  9. hibernate的各种保存方式的区别 (save,persist,update,saveOrUpdte,merge,flush,lock)等
  10. 多个相同script引用探索
  11. flexPaper +swftools实现文档在线阅读
  12. git 删除配置的远程地址
  13. C# 高效字符串连接 StringBuilder介绍
  14. rsyncd 配置使用
  15. 【温暖】文龙回AICODER给老马送锦旗了
  16. js动态规划---最少硬币找零问题
  17. The Little Prince-12/12
  18. js数据结构之列表的详细实现方法
  19. WIN10系统右击开始菜单没有属性选项怎么办
  20. 【LeetCode】207. Course Schedule (2 solutions)

热门文章

  1. run fsck manually
  2. Jlink更新新固件USB连接不上的问题
  3. Java科普之基础知识回顾
  4. 私有虚函数的特点(C++和Java的机制还有所不同)
  5. 快笑死,侯捷研究MFC的原因
  6. Android笔记——四大组件详解与总结
  7. 自己用反射写的一个request.getParameter工具类
  8. SparkContext和RDD
  9. Data Flow -&gt;&gt; Character Map
  10. Android 的 init.rc 文件简介【转】