Image mm = new Bitmap(10, 10); Graphics g = Graphics.FromImage(mm); g.DrawString("*-", this.Font, Brushes.Black, 0,5); TextureBrush b = new TextureBrush(mm); Pen p = new Pen(b,10);
g = this.CreateGraphics();
g.DrawLine(p, new Point(0, 50), new Point(200, 50));
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Drawing.Drawing2D;namespace WindowsApplication130 { public partial class Form1 : Form { public Form1() { InitializeComponent(); this.Paint += new PaintEventHandler(Form1_Paint); } void Form1_Paint(object sender, PaintEventArgs e) { Pen P = new Pen(Brushes.Red); P.DashPattern = new float[] { 5, 3, 1, 3 }; e.Graphics.DrawLine(P, new Point(0, 0), new Point(100, 100)); } } }
private void button1_Click(object sender, EventArgs e)
{
string strLine = "-*-*-*";
Graphics g = Graphics.FromHwnd(this.Handle);
g.DrawString(strLine,new Font(this.Font, FontStyle.Regular),Brushes.Red,new PointF(10,10));
}
Graphics g = Graphics.FromImage(mm);
g.DrawString("*-", this.Font, Brushes.Black, 0,5);
TextureBrush b = new TextureBrush(mm);
Pen p = new Pen(b,10);
g = this.CreateGraphics();
g.DrawLine(p, new Point(0, 50), new Point(200, 50));
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;namespace WindowsApplication130
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); this.Paint += new PaintEventHandler(Form1_Paint);
} void Form1_Paint(object sender, PaintEventArgs e)
{
Pen P = new Pen(Brushes.Red);
P.DashPattern = new float[] { 5, 3, 1, 3 };
e.Graphics.DrawLine(P, new Point(0, 0), new Point(100, 100));
}
}
}