Results 1 to 8 of 8

Thread: [3.0/LINQ] Non-responsive PictureBox?

  1. #1

    Thread Starter
    Lively Member Zolomon's Avatar
    Join Date
    Oct 2007
    Location
    Sweden
    Posts
    104

    Question [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

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3

    Thread Starter
    Lively Member Zolomon's Avatar
    Join Date
    Oct 2007
    Location
    Sweden
    Posts
    104

    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;
            }
    Last edited by Zolomon; Jan 22nd, 2008 at 03:16 PM.

  4. #4
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  5. #5

    Thread Starter
    Lively Member Zolomon's Avatar
    Join Date
    Oct 2007
    Location
    Sweden
    Posts
    104

    Re: [3.0/LINQ] Non-responsive PictureBox?

    Forgot to mention that if the MessageBox isn't there, none of the if-else statements execute.

  6. #6
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    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?
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  7. #7

    Thread Starter
    Lively Member Zolomon's Avatar
    Join Date
    Oct 2007
    Location
    Sweden
    Posts
    104

    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!)

  8. #8

    Thread Starter
    Lively Member Zolomon's Avatar
    Join Date
    Oct 2007
    Location
    Sweden
    Posts
    104

    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. (:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width