画图问题请问如何在直线的中间写几个字 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 style="TEXT-DECORATION: line-through" 忘了说是在WINFROM上用GDI+画的. private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.FillRectangle(Brushes.White, this.ClientRectangle); PointF p1 = new PointF(20, 100); PointF p2 = new PointF(200, 100); g.DrawLine(Pens.Black, p1, p2); g.DrawString("adfgsg", this.Font, Brushes.Black, p1.X + (p2.X - p1.X) / 2, p1.Y + (p2.Y - p1.Y) / 2 - this.Font.GetHeight()); } private void Form2_Paint(object sender, PaintEventArgs e) { //Graphics g = pe.Graphics; System.Drawing.Graphics formGraphics = this.CreateGraphics(); string drawString = "Sample Text"; System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16,FontStyle.Strikeout); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); float x = 150.0F; float y = 50.0F; System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat(); formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat); drawFont.Dispose(); drawBrush.Dispose(); formGraphics.Dispose(); } http://blog.csdn.net/knight94/archive/2006/03/25/638397.aspx图像旋转 private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; g.FillRectangle(Brushes.White, this.ClientRectangle); GraphicsPath gp = new GraphicsPath(); PointF p1 = new PointF(150, 100); PointF p2 = new PointF(300, 100); gp.AddLine(p1, p2); gp.AddString("adfgsg", new FontFamily("Times New Roman"),2, 16, new PointF( p1.X + (p2.X - p1.X) / 2, p1.Y + (p2.Y - p1.Y) / 2 - 16),StringFormat.GenericTypographic); g.RotateTransform(45); g.DrawPath(Pens.Black, gp); }用路径的rotate 就行了 winform 中listview的item项可不可放控件 为什么解决方案的根目录多了一个.suo的隐藏文件呢? C# 输入输出 新手问题?? WebBrowser控件的问题! 水晶报表2008加载速度的问题 怎样下载IBuySpy Portal? 为什么这两类编译不过 【100分求助】C#调用C++指向结构体的指针接口,获取数据错误 在窗体中,为什么要建一个components变量 变量 难题 求助 读取Excel数据出错,请求帮助
{
Graphics g = e.Graphics;
g.FillRectangle(Brushes.White, this.ClientRectangle); PointF p1 = new PointF(20, 100);
PointF p2 = new PointF(200, 100);
g.DrawLine(Pens.Black, p1, p2);
g.DrawString("adfgsg", this.Font, Brushes.Black, p1.X + (p2.X - p1.X) / 2, p1.Y + (p2.Y - p1.Y) / 2 - this.Font.GetHeight()); }
{
//Graphics g = pe.Graphics;
System.Drawing.Graphics formGraphics = this.CreateGraphics();
string drawString = "Sample Text";
System.Drawing.Font drawFont = new System.Drawing.Font("Arial", 16,FontStyle.Strikeout);
System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
float x = 150.0F;
float y = 50.0F;
System.Drawing.StringFormat drawFormat = new System.Drawing.StringFormat();
formGraphics.DrawString(drawString, drawFont, drawBrush, x, y, drawFormat);
drawFont.Dispose();
drawBrush.Dispose();
formGraphics.Dispose(); }
图像旋转
{
Graphics g = e.Graphics;
g.FillRectangle(Brushes.White, this.ClientRectangle);
GraphicsPath gp = new GraphicsPath();
PointF p1 = new PointF(150, 100);
PointF p2 = new PointF(300, 100);
gp.AddLine(p1, p2);
gp.AddString("adfgsg", new FontFamily("Times New Roman"),2, 16, new PointF( p1.X + (p2.X - p1.X) / 2, p1.Y + (p2.Y - p1.Y) / 2 - 16),StringFormat.GenericTypographic);
g.RotateTransform(45);
g.DrawPath(Pens.Black, gp); }
用路径的rotate 就行了