[转] 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 ...
随机推荐
- 一些时间的概念与区分(UTC、GMT、LT、TAI等)
UT - 世界时 Universal Time世界时是最早的时间标准.在1884年,国际上将1s确定为全年内每日平均长度的1/8.64×104.以此标准形成的时间系统,称为世界时,即 UT1.1972 ...
- iOS开发--提交github代码
将的SampleTable例子提交到github 具体步骤如下: a. 首先登陆github b. 创建新的reponsitory name, description c. 打开terminal, c ...
- 开放api设计资料收藏
REST设计 api设计范例http://www.ibm.com/developerworks/cn/web/1103_chenyan_restapi/index.html?ca=drs http:/ ...
- C++:四种必须使用初始化列表情况
[c++]必须在类初始化列表中初始化的几种情况 1. 类成员为const类型 2. 类成员为引用类型 复制代码 #include <iostream> using namesp ...
- POJ3020——Antenna Placement(二分图的最大匹配)
Antenna Placement DescriptionThe Global Aerial Research Centre has been allotted the task of buildin ...
- SpringBoot配置属性之Server
SpringBoot配置属性系列 SpringBoot配置属性之MVC SpringBoot配置属性之Server SpringBoot配置属性之DataSource SpringBoot配置属性之N ...
- TEET
[{"PROCESS_STORE_TIME":"3min 11s","PROCESS_GET_FILE_TIME":"3min&q ...
- minhash
minhash是一种基于jaccard index 相似度的算法.属于LSH(Location Sensitive Hash)家族中的一员. jaccard index :有两个集合A={a , b ...
- React getInitialState desc
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- SQL Server 数据库初始化准备脚本
通常我们在项目部署前都会写一份数据库初始化脚本.由于数据库外键的限制,我们需要按照数据引用顺序添加初始记录,这个整理过程相当麻烦. 因此写了以下脚本,原理是先去掉所有外键,然后执行一次清空,然后添加数 ...