[转] C# 绘制报表,使用Graphics.DrawString 方法
在指定位置并且用指定的 Brush 和Font 对象绘制指定的文本字符串。
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 方法的更多相关文章
- Graphics.DrawString 方法
MSDN上的解释: 在指定位置而且用指定的 Brush 和Font 对象绘制指定的文本字符串. public void DrawString( string s, Font font, Brush b ...
- 【转】Graphics.DrawImage 方法 IntPtr 结构 GDI 句柄 知识收集
Graphics.DrawImage 方法 在指定的位置使用原始物理大小绘制指定的 Image. 命名空间:System.Drawing 程序集:System.Drawing(在 system.dra ...
- 解决VS2015中没有报表项(ReportViewer)的方法
作者:何时.微笑成了种奢求 VS2015中没有报表项(ReportViewer),怎么办?这篇文章主要为大家详细介绍了解决VS2015中没有报表项(ReportViewer)的方法,感兴趣的小伙伴们可 ...
- 水晶报表的宽度调整方法(设计器、代码调整、rpt文件属性)
水晶报表的宽度调整方法(设计器.代码调整.rpt文件属性) Posted on 2010-08-07 23:52 moss_tan_jun 阅读(1725) 评论(0) 编辑 收藏 经过个人反复研究后 ...
- c# Graphics使用方法(画圆写字代码)
画填充圆: Graphics gra = this.pictureBox1.CreateGraphics(); gra.SmoothingMode = System.Drawing.Drawing2D ...
- JAVA GUI学习 - 窗体背景图片设置方法:重写paintComponent(Graphics g)方法
public class BackgroundImage extends JFrame { public BackgroundImage() { this.setTitle("窗体背景图片设 ...
- 纯Css绘制三角形箭头三种方法
在制作网页的过程中少不了绘制类似图片的三角形箭头效果,虽然工程量不大,但是确实麻烦.在学习的过程中,总结了以下三种方法,以及相关的例子. 一.三种绘制三角形箭头方法 1.方法一:利用overflow: ...
- UniGui中使用Grid++Report报表控件子报表获取数据的方法
Grid++Report是为优秀的报表控件,子报表是其重要功能之一,但Grid++Report提供的网页报表示范主要是以页面为主的,UniGui在Delphi中以快速编写web管理软件著称,但由于资料 ...
- canvas绘制爱心的几种方法
第一种方法:桃心形公式 代码实现的一种方法 <!DOCTYPE html> <html lang="en"> <head> <meta c ...
随机推荐
- CSS布局:让页底内容永远固定在底部
我们在设计一些页面内容甚少的网页时(典型应用就是登陆页面),由于显示器的分辨率大,在正常情况下,假如页面内容高度小于浏览器高度时,页面底部以下会留下很大的空间... 先看示例:http://www.h ...
- iOS开发--动画篇之layout动画深入
"不得不说,单单是文章的标题,可能不足以说明本文的内容.因此,在继续讲述约束动画之前,我先放上本文要实现的动画效果." 编辑:Bison投稿:Sindri的小巢 约束动画并不是非常 ...
- 返回Json数据浏览器带上<pre></pre>标签解决方法
问题: 当后台获取到前台传来的文件时(例如上传功能, 导入功能), 返回类型为application/json, 这个时候响应到前端的JSON格式的数据格式可能是: <pre style=&q ...
- http://blog.csdn.net/lvyuanj/article/details/51235135
http://blog.csdn.net/lvyuanj/article/details/51235135
- java Cache框架
Cache框架乱炖 各类开源的缓存解决方案 JBossCache/TreeCacheJBossCache是一个复制的事务处理缓存,它允许你缓存企业级应用数据来更好的改善性能.缓存数据被自动复制,让 ...
- Control character in cookie value, consider BASE64 encoding your value
这是因为你给Cookie设置了中文的value,比如Cookie c = new Cookie("user", "张三");
- 360每日自动签到,领取积分 (java httpclient4.x)
如何登陆360,并每日自动签到这次的难点主要集中在登陆这里了,开始抓包发现360登陆验证很麻烦,但是后来发现一个简单的方法.因为我安装了360安全卫士,发现点击那个金币的按钮能直接验证登陆,哈哈~所以 ...
- 用xshell操作linux系统的常用命令
(1)命令ls——列出文件 ls -la 给出当前目录下所有文件的一个长列表,包括以句点开头的“隐藏”文件 ls a* 列出当前目录下以字母a开头的所有文件 ls -l *.doc 给出当前目录下以. ...
- [原]poj2243-Knight Moves-水bfs
#include<iostream> #include<cstdio> #include<cstring> #include<queue> using ...
- 《OD学Sqoop》数据转换工具Sqoop
一. 第二阶段课程回顾 hadoop 2.x HDFS YARN MapReduce Zookeeper Hive 二.大数据协作框架 对日志类型的海量数据进行分析 hdfs mapreduce/hi ...