Anthony

Anthony

  • NA
  • 17
  • 0

C# - Can't call a new pen. Did I miss something?

Jul 26 2008 1:30 AM

Okay, I am trying to make a custom pen to draw a simple border around a picture, but for some reason, I get a message saying that
"System.Drawing.Pen does not have a definition for objSteelSolid" I don't get this one. I declared the object under the Pen type, but it still doesn't recognise it as a pen? What gives?

private void btnDrawBorder_Click(object sender, EventArgs e)
{
Graphics objGraphics = null;
objGraphics =
this.CreateGraphics();
objGraphics.Clear(
SystemColors.Control);

//new pen
Pen objSteelSolid = new Pen(Color.SteelBlue, 5);
objMyPen.DashStyle = System.Drawing.Drawing2D.
DashStyle.Solid;

objGraphics.DrawRectangle(
Pen.objSteelSolid, //ERROR!
picBox.Left - 1, picBox.Top - 1,
picBox.Width + 1, picBox.Height + 1);
objGraphics.Dispose();
}


Answers (2)