Hi all,
I'm working in C#. I have 3 forms. On the 1st form I have a single "NEXT" button. In its click event I'm hiding the currently active form (1st), creating an instance of the 2nd form and showing it.
On the next 2 forms, apart from the next button (who's click events are similar to that of the 1st form's next button), I have "BACK" buttons. In these buttons I want to show the previously hidden forms. How do I do it?
Please help
Amey
[Reply = Rajaprakash]
Hi,
In the first Form's button click event, set the 1st Form enabled property as false then create the instance of the 2nd form and showing it and pass the 1st form using write a method in 2nd form which parameter set as object
In 2nd Form's "Back" button event, close the 2nd Form then set the 1st Form's enabled property as True.
For Example,Form1 have "Next" Button and Form2 have "Back" Button.
Form1
1.Write the code in Form1 Next button click event.
private void btnNext_Click(object sender, EventArgs e)
{
Form1.ActiveForm.Enabled = false;
Form2 frmObj = new Form2();
frmObj.Show();
frmObj.ActveForm(this);
}
Form2
1. Declare the Form1 in Form2 class.
2. Write a method in Form2 and assign the Form1 in the local form.
3. Wirte the code in Form2 Back button click event.
private Form1 frmFirst;
public void ActveForm(Object recForm)
{
frmFirst= (Form1)recForm;
}
private void btnBack_Click(object sender, EventArgs e)
{
this.Close();
frmFirst.Enabled = true;
}
Can you try this. It'll work.
Rajaprakash
[/Reply]