Here I managed to do it using a hard coded rectangle.
<pre lang="cs">
private bool selectGraph = false;
private Rectangle myrec = new Rectangle(50, 50, 100, 100);
private Graphics g;
private void panel1_Paint(object sender, PaintEventArgs e)
{
g = panel1.CreateGraphics();
SolidBrush sb = new SolidBrush(Color.Blue);
Pen p = new Pen(Color.Blue, 5);
g.DrawRectangle(p, myrec);
g.FillRectangle(sb, myrec);
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
Point mPT = new Point(e.X, e.Y);
if (e.Button == MouseButtons.Left)
{
if (myrec.Contains(mPT))
{
selectGraph = true;
button1.Enabled = true;
}
else
{
selectGraph = false;
button1.Enabled = false;
}
}
Invalidate();
}
But what I want is a runtime draw line. :doh: