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. [置顶] ※数据结构※→☆线性表结构(queue)☆============循环队列 顺序存储结构(queue circular sequence)(十)

    循环队列 为充分利用向量空间,克服"假溢出"现象的方法是:将向量空间想象为一个首尾相接的圆环,并称这种向量为循环向量.存储在其中的队列称为循环队列(Circular Queue). ...

  2. 与众不同 windows phone (24) - Input(输入)之软键盘类型, XNA 方式启动软键盘, UIElement 的 Touch 相关事件, 触摸涂鸦

    原文:与众不同 windows phone (24) - Input(输入)之软键盘类型, XNA 方式启动软键盘, UIElement 的 Touch 相关事件, 触摸涂鸦 [索引页][源码下载] ...

  3. 搜索:POJ2251&POJ1426&POJ3087&POJ2488

    图的遍历也称为搜索,就是从图中某个顶点出发,沿着一些边遍历图中所有的顶点,且每个顶点仅被访问一次,遍历可采取两种不同的方式:深度优先搜索(DFS)和广度优先搜索(BFS). 1.DFS算法思想` 从顶 ...

  4. POJ2421 & HDU1102 Constructing Roads(最小生成树)

    嘎唔!~又一次POJ过了HDU错了...不禁让我想起前两天的的Is it a tree?   orz..这次竟然错在HDU一定要是多组数据输入输出!(无力吐槽TT)..题目很简单,炒鸡水! 题意: 告 ...

  5. Android开发经验之—intent传递大数据

    在Activity或者组件之前传递信息时,一般採用intent绑定bundle的方式传值,但在使用过程中须要注意的是不要用bundle传递大容量数据: 在做项目的过程中,须要将听写界面的听写结果信息传 ...

  6. Java+7入门经典 - 6 扩展类与继承 Part 2/2

    6.12 设计类 1) 通过已定义的基类派生子类, 并且添加方法和数据成员来自定义子类, 创建出类的层次结构; Dog 'IS-A' Animal 2) 定义一系列没有层次结构, 由类对象作为数据成员 ...

  7. IOS中的ViewController 的loadView、viewDidLoad、viewDidUnload

    由init.loadView.viewDidLoad.viewDidUnload.dealloc的关系说起: 1 init方法 在init方法中实例化必要的对象(遵从LazyLoad思想) init方 ...

  8. ie浏览器提交参数和其它浏览器的区别

    场景描述: 用户注册模块(ajax提交方式,post方法),在url后追加了一个参数,如:url+‘btnvalue=中文参数’,如此在非ie浏览器注册时,功能完好,但在ie下注册不成功.调式后发现在 ...

  9. python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overflow

    python - ImportError: No module named http.cookies error when installing cherrypy 3.2 - Stack Overfl ...

  10. HDU 4704 Sum (费马定理+快速幂)

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Subm ...