请问一下,我想在一个黑色背景的PictureBox里生成白色直线,用Graphics的Drawline写了一个,运行的时候没有显示出来是为什么啊
以下是代码
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TestDrawing
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Graphics g = pictureBox1.CreateGraphics();
g.DrawLine(new Pen(Color.White,2), 0, pictureBox1.Height / 2, pictureBox1.Width, pictureBox1.Height / 2);
g.Dispose();
}
}
}