Graphics.DrawString 方法
MSDN上的解释:
在指定位置而且用指定的 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);
}
Graphics.DrawString 方法的更多相关文章
- [转] C# 绘制报表,使用Graphics.DrawString 方法
原文 Graphics.DrawString 方法 在指定位置并且用指定的 Brush 和Font 对象绘制指定的文本字符串. public void DrawString( string s, Fo ...
- 【转】Graphics.DrawImage 方法 IntPtr 结构 GDI 句柄 知识收集
Graphics.DrawImage 方法 在指定的位置使用原始物理大小绘制指定的 Image. 命名空间:System.Drawing 程序集:System.Drawing(在 system.dra ...
- 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("窗体背景图片设 ...
- graphics.drawRect()方法
drawRect方法的官方API文档描述 drawRect public void drawRect(int x, int y, int width, int height) Draws the ou ...
- android.graphics.Paint方法setXfermode (Xfermode x...
mPaint = new Paint(); mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN)); 常见的Xfermod ...
- VB6与VB.NET对照表
VB6与VB.NET对照表 VB6.0 VB.NET AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1.It ...
- VB6.0 和VB.NET 函数对比
VB6.0和VB.Net的对照表 VB6.0 VB.NET AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1 ...
- VB6.0和VB.Net的函数等对照表
VB6.0和VB.Net的对照表 VB6.0 VB.NET AddItem Object名.AddItem Object名.Items.Add ListBox1.Items.Add ComboBox1 ...
随机推荐
- OCA读书笔记(5) - 管理ASM实例
Objectives:Describe the benefits of using ASMManage the ASM instanceCreate and drop ASM disk groupsE ...
- Java常用代码段 - 未完待续
记录一些自己写项目常用的代码段. 格式化常用日期格式 Date date = new Date(System.currentTimeMillis()); DateFormat d3 = DateFor ...
- Java使用javax.mail.jar发送邮件并同意发送附件
因为Java在开发网页上占有绝大优势.所以作为web端的领军人物,譬如发送短信和发送邮件这些就成了必定,网络安全一再安全我们须要把账号的安全级别提到更高.因此这些对于开发者也就成了必须掌握的技能!我一 ...
- Swift - 使用arc4random()、arc4random_uniform()取得随机数
arc4random()这个全局函数会生成9位数的随机整数 1,下面是使用arc4random函数求一个1~100的随机数(包括1和100) 1 var temp:Int = Int(arc4ra ...
- Android自定义shape的使用
MainActivity如下: package cn.testshape; import android.os.Bundle; import android.app.Activity; /** * D ...
- Java编码浅析(注意区分三个概念)(转)
编码: (1)外部资源的字符集-----没有读入jvm中的数据都是外部资源 (2)jvm中数据的字符集-----都是unicode (1)和(2)之间发生交互时,如果不指定编码,则使用JVM平台默认字 ...
- 一步步学习Linux开发环境搭建与使用
00.Linux开发环境搭建与使用1--Linux简史 01.Linux开发环境搭建与使用2--Linux系统(ubuntu)安装方案 02.Linux开发环境搭建与使用3--通过虚拟机安装系统(ub ...
- DataReader和DataSet的区别以及使用
DataReader和DataSet这两个对象都可以将检索的关系数据存储在内存中.它们在功能使用方面非常相似,但是它们不可以相互替换. 主要区别如表所示: DataReader DataSet 数 ...
- POJ 3076 Sudoku (dancing links)
题目大意: 16*16的数独. 思路分析: 多说无益. 想说的就是dancing links 的行是依照 第一行第一列填 1 第一行第二列填 2 -- 第一行第十五列填15 第一行第二列填 1 -- ...
- OCP读书笔记(12) - 执行闪回数据库
闪回数据库使用的是闪回日志,闪回日志存在于闪回目录(也就是快速闪回区中)闪回日志:就是数据块修改之前的镜像,简称前像 1.查看闪回目录的位置:show parameter recovery 如果闪回目 ...