OriginalGriff is correct: you have not set the Tag; the cast to 'BorderStyle is valid. So, vote his answer up, not this one :)
I don't think you need an 'enum here because ... but, first, a few words about 'enum:
All C# Enumerations store an internal value of some numeric type: "The approved types for an enum are byte, sbyte, short, ushort, int, uint, long, or ulong:" [
^].
When you set a WinForm Control's 'Tag property, what you set it
to is cast to an object (i.e., boxed). If you set it to a nullable, or reference, Type, you can retrieve the value using the 'As operator, which is convenient because it will return 'null if the cast did not work. An 'enum value is not a reference Type, not nullable: so, you can't use 'As.
Now, about your code: consider:
PictureBox pb;
private void PictureBoxes_MouseEnter(object sender, System.EventArgs e)
{
pb = sender as PictureBox;
pb.BorderStyle = BorderStyle.Fixed3D;
}
private void PictureBoxes_MouseLeave(object sender, System.EventArgs e)
{
if(pb.ImageLocation == null)
{
pb.BorderStyle = BorderStyle.None;
}
}
Then your 'Click event handler simplifies to only setting the 'ImageLocation property on left-mouse down.