[3.0/LINQ] Non-responsive PictureBox?
Hello!
I have yet another problem which I can't seem to solve.
I have a pictureBox update its image to a new one, depending
on whether a boolean is true or false, and whether the first
image equals an already set one.
I can get the images to change, but only if I have a MessageBox.Show()
before my if-else statements.
Any thoughts?
Source: http://monoport.com/6633
Appreciates any help at all!
Cheers,
Zolomon
Re: [3.0/LINQ] Non-responsive PictureBox?
Could you post only the relevant code here? Its so much easier than looking through all of it.
Re: [3.0/LINQ] Non-responsive PictureBox?
Of course, forgot to mention which lines it was, my bad. (:
http://monoport.com/6637
Code:
private void pbx1_Click(object sender, EventArgs e)
{
MessageBox.Show(((PictureBox)sender).Tag.ToString());
if (Check(((PictureBox)sender), imgBoard) == true)
{
if (CheckPlayerState(bPlayerState) == true)
{
((PictureBox)sender).Image = imgPlayer1;
tSSLStatus.Text = "Player 2's turn...";
bPlayerState = false;
}
else if (CheckPlayerState(bPlayerState) == false)
{
((PictureBox)sender).Image = imgPlayer2;
tSSLStatus.Text = "Player 1's turn...";
bPlayerState = true;
}
}
else if (Check(((PictureBox)sender), imgPlayer1))
{
MessageBox.Show("Tile already picked. Repick!");
}
else if (Check(((PictureBox)sender), imgPlayer2))
{
MessageBox.Show("Tile already picked. Repick!");
}
//((PictureBox)sender).Enabled = false;
}
Re: [3.0/LINQ] Non-responsive PictureBox?
So the image isnt being shown directly? Try calling the picturebox refresh method after setting the image property.
Re: [3.0/LINQ] Non-responsive PictureBox?
Forgot to mention that if the MessageBox isn't there, none of the if-else statements execute.
Re: [3.0/LINQ] Non-responsive PictureBox?
Quote:
Originally Posted by Zolomon
Forgot to mention that if the MessageBox isn't there, none of the if-else statements execute.
Have you stepped through the code to see whats really happening?
Re: [3.0/LINQ] Non-responsive PictureBox?
I just tried, but I can't really make much out of it. The Image property for the PictureBox that I look at only says System.Drawing.Bitmap (which I think is what I should've looked for), so I couldn't see when it changed or not, or when it should've had opportunity for it..
I could upload the full project in case you feel like digging in to it.
(I'm way more than grateful for the help you've given me so far already!)
Re: [3.0/LINQ] Non-responsive PictureBox?
Uploaded source & project to:
http://www.zolomon.eu/misc/TicTacToe.rar if anyone feels like taking a deeper look at my problem. (: