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;
}
}
}
}
Loading
VulpesPosted Dec 29, 2011, 9:12 AM
Caleb DunnPosted Dec 29, 2011, 8:01 PM
VulpesPosted Dec 29, 2011, 6:52 PM
Caleb DunnPosted Dec 29, 2011, 6:15 PM
VulpesPosted Dec 29, 2011, 5:54 PM
Caleb DunnPosted Dec 29, 2011, 5:31 PM
since it messes the rest of the code up and causes an already defined error. Its because of the button name at the top. So somthing needs to be changed. Also thanks for helping me so much, ive been working on this for a project.
int counter = 0;
int maximum = 2; //Maximium = total panels started from 0, 1, 2
private void fusionButton5_Click(object sender, EventArgs e) <----THIS LINE
{
counter++;//the ++ after a integer raises the value by 1
if (counter > 0)//checks to see if counter value is greater than 1
{
fusionButton4.Enabled = true;
}
if (counter == maximum) //checks to see if counter is equal to that of maximum
{
fusionButton5.Enabled = false;
}
}
VulpesPosted Dec 29, 2011, 4:33 PM
Mahesh ChandPosted Dec 29, 2011, 2:35 PM
Caleb DunnPosted Dec 29, 2011, 1:50 PM
Caleb DunnPosted Dec 29, 2011, 9:00 AM
VulpesPosted Dec 29, 2011, 7:01 AM
If you're still not seeing the buttons enable/disable, I'd make sure that you've added the Click handlers from the VS designer and not just pasted them in. The events will be automatically wired up to the handlers in the former case but, in the latter case, you'd need to do it 'manually' by adding these lines in (say) Form1_Load:
fusionButton4.Click += fusionButton4_Click;
fusionButton5.Click += fusionButton5.Click;