0

In C#, using Visual Studio 2019, I have run into a bizarre problem that makes literally no sense. I've been working on a program based on the Who Wants to be a Millionaire game show. For some reason, changing one PictureBox to visible, apparently is making 4 other PictureBoxes and 4 labels not want to become visible. Here's what I mean.

The following code....

private void pbATA_Click(object sender, EventArgs e)
    {
        if (LifeLineStat[3] == 0 && GameOver == 0 && SelectedAnswer == 0 && LifelineActive == 0)
        {
            LifelineActive = 1;

            LifeLineStat[3] = 1;
            pbATA.Visible = false;
            pbATAUsed.Visible = true;

            timRaiseLights.Enabled = true;

            Music[1].Stop();
            Music[3] = new System.Media.SoundPlayer(@"Audio\ATA1.wav");
            Music[3].Play();
            timATA1.Enabled = true;
        }
    }

.... results in this: enter image description here

But this code....

private void pbATA_Click(object sender, EventArgs e)
    {
        if (LifeLineStat[3] == 0 && GameOver == 0 && SelectedAnswer == 0 && LifelineActive == 0)
        {
            LifelineActive = 1;

            LifeLineStat[3] = 1;
            pbATA.Visible = false;
            //pbATAUsed.Visible = true;

            timRaiseLights.Enabled = true;

            Music[1].Stop();
            Music[3] = new System.Media.SoundPlayer(@"Audio\ATA1.wav");
            Music[3].Play();
            timATA1.Enabled = true;
        }
    }

.... results in this:

enter image description here

Why would changing the state of JUST pbATAUsed.Visible make the Ask The Audience bars and percentages not show up?!

  • Looks as if there is other code involved. Use the debugger to step though all events.. `VisibleChanged` comes to mind.. – TaW Sep 27 '21 at 16:57
  • I used Console.WriteLine(); ("Console.WriteLine(pbATABar1.Visible);" , for example) when selecting an answer, after using Ask The Audience. All of them show as "true", even though they clearly aren't visible at all. – Taylor Woolston Sep 27 '21 at 17:36
  • Okay, apparently somehow they either got sent to to the back, or the graph got sent to the front. Even though I don't have any code telling it to do that at all, let alone specifically when a certain PictureBox is visible or not. Anyways, I fixed it with a .SendToBack() command. – Taylor Woolston Sep 27 '21 at 17:43

0 Answers0