public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.panel1.BackColor = Color.White;
Graphics graphics = this.panel1.CreateGraphics(); //
graphics.DrawLine(new Pen(Color.Black, 2), 0, this.panel1.Top, this.panel1.Left + 5, this.panel1.Bottom);
graphics.Dispose();
Graphics g = panel1.CreateGraphics();
Rectangle rect = new Rectangle((panel1.Width / 2) - 128, (panel1.Height / 2) - 152, 256, 304);
g.DrawRectangle(new Pen(Color.Lime, 2), rect);
g.Dispose();
}
}
效果如下:
没有看到有划线,请问下是代码是有什么问题吗?