나는 이것에 초심자이다 그래서 조금 느슨하게 저를 자르십시오. 마우스를 클릭 한 위치에서 양식 창에 점을 그리려는 중입니다. g.FillEllipse에서 Null 예외가 계속 발생합니다. 나는 무엇을 놓치고 잘못 했는가?g.FillEllipse()를 사용할 때 계속 Null 예외가 발생합니다.
namespace ConvexHullScan
{
public partial class convexHullForm : Form
{
Graphics g;
//Brush blue = new SolidBrush(Color.Blue);
Pen bluePen = new Pen(Color.Blue, 10);
Pen redPen = new Pen(Color.Red);
public convexHullForm()
{
InitializeComponent();
}
private void mainForm_Load(object sender, EventArgs e)
{
Graphics g = this.CreateGraphics();
}
private void convexHullForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
int x, y;
Brush blue = new SolidBrush(Color.Blue);
x = e.X;
y = e.Y;
**g.FillEllipse(blue, x, y, 20, 20);**
}
}
}
}