Ok I'm trying to derive from the picturebox control in System.Windows.Forms and set it to a default pic that can be changed via a setPic method.
It's supposed to be a blank box that changes to a red x when the user gets a question wrong...
using System;
using System.Drawing;
using System.Windows.Forms;
namespace Fraction_Game
{
public class xBox : System.Windows.Forms.PictureBox
{
const byte a = 20;
public xBox()
{
this.Size = new Size(a, a);
this.setPic(true);
}
public void setPic(bool correct)
{
string path;
this.SizeMode = PictureBoxSizeMode.Normal;
if (correct)
{
path =
@BlankX.BMP;
}
else
{
path =
@RedX.BMP;
}
this.Image = Image.FromFile(path);
}
}
Every time I try to add the control to the form, I get a FileNotFoundException. It can't load the blankX.bmp file, which is in the same directory as the project, right clicked and selected "include in project" and everything. I have tried using various iterations of the file name... "~/BlankX.bmp" ,
@~/BlankX.bmp etc etc and nothing seems to work.
I can only assume there's some property of PictureBox that I'm unaware of that I need to set? nothing that I can figure out.
Anyone?
Comments
><//~Psightoplasm`~