11
Answers

Can somone check this C#?

Caleb Dunn

Caleb Dunn

12y
3.1k
1
In my program im trying to add back and forth buttons using panels. By back and forth buttons I mean buttons that go back to other forms and the other one goes to the forms after. Im using microsoft visual studio C#. The problem is when I click the buttons nothing happens.

Heres the code I used:


  int counter = 0;
  int maximum = 2; //Maximium = total panels started from 0, 1, 2
  private void fusionButton5_Click(object sender, EventArgs e)
  {
  counter++;//the ++ after a integer raises the value by 1
  if (counter > 0)//checks to see if counter value is greater than 1
  {
  fusionButton5.Enabled = true;
  }
  if (counter == maximum) //checks to see if counter is equal to that of maximum
  {
  fusionButton4.Enabled = false;
  }
  }

  private void fusionButton4_Click(object sender, EventArgs e)
  {
  if (counter > 0)
  {
  counter--;//the -- after integer lowers the value by 1
  if (counter == 0)
  {
  fusionButton4.Enabled = false;
  }
  }
  if (counter < maximum)
  {
  fusionButton5.Enabled = true;
  }
  }

  private void panelcontrol_Tick(object sender, EventArgs e)
  {
  switch (counter)
  {
  case 0:
  panel1.Visible = true;
  panel2.Visible = false;
  break;
  case 1:
  panel1.Visible = false;
  panel2.Visible = true;
  panel3.Visible = false;
  break;
  case 2:
  panel2.Visible = false;
  panel3.Visible = true;
  break;
  }
  }
  }
}

Answers (11)