MSDN上的解释:

在指定位置而且用指定的 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);

}

Graphics.DrawString 方法的更多相关文章

  1. [转] C# 绘制报表,使用Graphics.DrawString 方法

    原文 Graphics.DrawString 方法 在指定位置并且用指定的 Brush 和Font 对象绘制指定的文本字符串. public void DrawString( string s, Fo ...

  2. 【转】Graphics.DrawImage 方法 IntPtr 结构 GDI 句柄 知识收集

    Graphics.DrawImage 方法 在指定的位置使用原始物理大小绘制指定的 Image. 命名空间:System.Drawing 程序集:System.Drawing(在 system.dra ...

  3. c# Graphics使用方法(画圆写字代码)

    画填充圆: Graphics gra = this.pictureBox1.CreateGraphics(); gra.SmoothingMode = System.Drawing.Drawing2D ...

  4. JAVA GUI学习 - 窗体背景图片设置方法:重写paintComponent(Graphics g)方法

    public class BackgroundImage extends JFrame { public BackgroundImage() { this.setTitle("窗体背景图片设 ...

  5. graphics.drawRect()方法

    drawRect方法的官方API文档描述 drawRect public void drawRect(int x, int y, int width, int height) Draws the ou ...

  6. android.graphics.Paint方法setXfermode (Xfermode x...

    mPaint = new Paint(); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN)); 常见的Xfermod ...

  7. VB6与VB.NET对照表

    VB6与VB.NET对照表 VB6.0 VB.NET AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1.It ...

  8. VB6.0 和VB.NET 函数对比

    VB6.0和VB.Net的对照表 VB6.0 VB.NET AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1 ...

  9. VB6.0和VB.Net的函数等对照表

    VB6.0和VB.Net的对照表 VB6.0 VB.NET AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1 ...

随机推荐

  1. 一个解析RTSP 的URL函数

    写了一个解析URL的函数,可以提取URL中的IP 和 port. 如:url = "rtsp://192.168.1.43:2554/realmp3.mp3"; url = &qu ...

  2. [知识库分享系列] 二、Web(高性能Web站点建设)

    知识库分享系列: [知识库分享系列] 二..NET(ASP.NET) [知识库分享系列] 一.开篇 分享介绍 此知识库之所以为 Web 系列,因为和 .NET 没有完全的关系,其中的技术和实践实用于各 ...

  3. 百度地图 javascript相关Bug搜集

    一 在手机里用百度地图js版做webapp   bug集合 1 之前用2.0版本的时候发现只要地图添加了覆盖物,无论数量多少,当地图放大到很小的范围时候,会卡死 1.1 当时处理办法:将版本降低至1. ...

  4. JDWP

    JPDA(Java Platform Debugger Architecture) 是 Java 平台调试体系结构的缩写,通过 JPDA 提供的 API,开发人员可以方便灵活的搭建 Java 调试应用 ...

  5. (step4.3.9)hdu 1584(蜘蛛牌——DFS)

    题目大意:本体是中文题,可以直接在OJ上看 /* * 1584_2.cpp * * Created on: 2013年8月22日 * Author: Administrator */ #include ...

  6. drupal进入不了后台时候的解决办法,作者使用drush方案,已验证

    drupal把正在用的主题不小心删了,怎么进后台? 方法一: 去variable表里把默认主题换了 方法二: ?q=user 登录到管理区,开启简洁连接使用user(网站根目录下面) admin/ap ...

  7. Cocos2d-x3.3RC0的Android编译Activity启动流程分析

    本文将从引擎源代码Jni分析Cocos2d-x3.3RC0的Android Activity的启动流程,以下是具体分析. 1.引擎源代码Jni.部分Java层和C++层代码分析 watermark/2 ...

  8. K-means clustering (K-means聚类)

    问题: K-所有值聚类是无监督学习算法 设数据集.当中,. 如果这个数据能够分为类. 把这个问题模型化: , 当中代表第类的聚点(中心点.均值). 该模型能够用EM算法进行训练: 初始化,. E步:固 ...

  9. Java泛型之<T>

    这里不讲泛型的概念和基础知识,就单纯的就我的理解说一下泛型中的<T> 一. <T> 下面的一段码就可以简单使用了<T>参数,注释就是对<T>的解释. p ...

  10. Python编程中常用的12种基础知识总结

    原地址:http://blog.jobbole.com/48541/ Python编程中常用的12种基础知识总结:正则表达式替换,遍历目录方法,列表按列排序.去重,字典排序,字典.列表.字符串互转,时 ...