原文 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. SSDP 简单服务发现协议

    http://blog.csdn.net/lilypp/article/details/6631951

  2. Java-J2SE学习笔记-线程-生产者消费者问题

    一.概述 模拟生产者消费者问题 二.代码 1.Consumer.java 2.Producer.java 3.SyncStack.java 4.Test.java 1.Consumer.java pa ...

  3. 世界上还有一个东西叫Virtual Pascal

    官网是:http://web.archive.org/web/20060312064321/http://www.vpascal.com/news.php?item.16 不过2005年就不再维护了. ...

  4. Android AlarmManager(全局定时器/闹钟)指定时长或以周期形式执行某项操作

    AlarmManager的使用机制有的称呼为全局定时器,有的称呼为闹钟.通过对它的使用,个人觉得叫全局定时器比较合适,其实它的作用和Timer有点相似.都有两种相似的用法:(1)在指定时长后执行某项操 ...

  5. 无图片,用css border实现尖三角

    <!DOCTYPE HTML> <html> <head> <meta charset="gbk" /> <style typ ...

  6. R.id.layout等不能识别:cannot be resolved or is not a field

    Do not modify the R class. The error means there's something syntactically wrong with your XML layou ...

  7. Linux内核的整体架构

    Linux内核的整体架构 作者:蜗蜗 发布于:2014-2-21 13:23 分类:Linux内核分析 原文:http://www.wowotech.net/linux_kenrel/11.html ...

  8. 《OD大数据实战》Flume环境搭建

    一.CentOS 6.4安装Nginx http://shiyanjun.cn/archives/72.html 二.安装Flume 1. 下载flume-ng-1.5.0-cdh5.3.6.tar. ...

  9. ArrayAdapter参数的不同运用

    ArrayAdapter参数不同带来的效果不同 String[] array = {"a","b","c","d",&q ...

  10. Jquery Highcharts 参数配置说明

    chart: renderTo 图表的页面显示容器 defaultSeriesType 图表的显示类型(line,spline, scatter, splinearea bar,pie,area,co ...