I'm a newbie C# programmer, and I would like to ask for help on this error.
I was trying to get a button to change its image when it is clicked, a task that sounds so simple, I know, but whenever I run the program and click said button, it returns a NullReferenceException error.
This is the code that causes the error, I think. The rest of the program is too long, even if it does nothing.
private void btnA1_Click(object sender, EventArgs e)
{
if (a1 == false)
{
btnPassChar = "A1";
a1 = true;
btnA1.Image.Equals(@"G:/MCL/IT126L/CircuitCreator/CircuitCreator/bin/Debug/btnWhiteBack.png");
}
else
{
btnPassChar = "XX";
a1 = false;
MessageBox.Show("True to false");
}
}
I understand that putting in a path for the Image may not be the smartest thing to do. Still, it's the only thing on my mind right now.
If it's any help, I'm using Windows 7. Had the Visual Studio 2005 on Run as Admin rights. Also, the PNG file DOES exist. I made it myself.