原文 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); }

												

[转] C# 绘制报表,使用Graphics.DrawString 方法的更多相关文章

  1. Graphics.DrawString 方法

    MSDN上的解释: 在指定位置而且用指定的 Brush 和Font 对象绘制指定的文本字符串. public void DrawString( string s, Font font, Brush b ...

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

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

  3. 解决VS2015中没有报表项(ReportViewer)的方法

    作者:何时.微笑成了种奢求 VS2015中没有报表项(ReportViewer),怎么办?这篇文章主要为大家详细介绍了解决VS2015中没有报表项(ReportViewer)的方法,感兴趣的小伙伴们可 ...

  4. 水晶报表的宽度调整方法(设计器、代码调整、rpt文件属性)

    水晶报表的宽度调整方法(设计器.代码调整.rpt文件属性) Posted on 2010-08-07 23:52 moss_tan_jun 阅读(1725) 评论(0) 编辑 收藏 经过个人反复研究后 ...

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

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

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

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

  7. 纯Css绘制三角形箭头三种方法

    在制作网页的过程中少不了绘制类似图片的三角形箭头效果,虽然工程量不大,但是确实麻烦.在学习的过程中,总结了以下三种方法,以及相关的例子. 一.三种绘制三角形箭头方法 1.方法一:利用overflow: ...

  8. UniGui中使用Grid++Report报表控件子报表获取数据的方法

    Grid++Report是为优秀的报表控件,子报表是其重要功能之一,但Grid++Report提供的网页报表示范主要是以页面为主的,UniGui在Delphi中以快速编写web管理软件著称,但由于资料 ...

  9. canvas绘制爱心的几种方法

    第一种方法:桃心形公式 代码实现的一种方法 <!DOCTYPE html> <html lang="en"> <head> <meta c ...

随机推荐

  1. CentOS 7快速搭建Nodejs开发环境

    Node.js是一个事件驱动I/O服务端JavaScript环境,基于Google的V8引擎,V8引擎执行Javascript的速度非常快,性能非常好.学习Nodejs首先需要会安装环境.这里我介绍如 ...

  2. ES6入门之Symbol

    ES5对象属性名都是字符串容易造成属性名的冲突. eg:var a = { name: 'lucy'}; a.name = 'lili';这样就会重写属性 ES6引入了一种新的原始数据类型Symbol ...

  3. 【流媒体】 Android 实时视频编码—H.264硬编码

    [流媒體] Android 实时视频编码—H.264硬编码 SkySeraph Apr 4th 2012 Email:skyseraph00@163.com 1  硬编码 & 软编码 硬编码: ...

  4. opencv 人脸识别 (一)训练样本的处理

    本文实现基于eigenface的人脸检测与识别.给定一个图像数据库,进行以下步骤: 进行人脸检测,将检测出的人脸存入数据库2 对数据库2进行人脸建模 在测试集上进行recognition   本篇实现 ...

  5. Write operations are not allowed in read-only mode

    使用Spring提供的Open Session In View而引起Write operations are not allowed in read-only mode (FlushMode.NEVE ...

  6. vb.net 写入文件同步锁

    <SoapHeader("oHeader")> _ <WebMethod()> _ <ScriptMethod(ResponseFormat:=Res ...

  7. 【玩转Ubuntu】09. Ubuntu上安装apktool

    下载两个文件 到这里 https://code.google.com/p/android-apktool/downloads/list?q=label:Featured下载这个文件  1.  apkt ...

  8. JSP或HTML命名规范

    1.jsp与html文件名全部小写 2.数据/内容显示页 名词形式,多个单词用下划线分隔,要求能说明显示内容的信息,为避免冲突,可加上“_list”或者其他的单词.例如:news_message.ht ...

  9. Ubuntu14.04安装和配置Tomcat8.0.12

    Ubuntu14.04长的好看,所以一时间很感兴趣,研究各种软件的安装和开发环境的配置.今天先把安装的tomcat 8.0.12的教程分享给大家.如果你需要,请收藏!!!   官方网站下载最新的tom ...

  10. eclipse中启动tomcat报错 java.lang.ClassNotFoundException

    之前启动还好好的,某次启动tomcat就莫名其妙的报了这个java.lang.ClassNotFoundException的错.   检查maven依赖包,发现这个类是存在的. 然后一通clean操作 ...