|
-
March 10th, 2006, 04:02 PM
#1
Navigating between multiple forms in C#
Hi,
I have been looking for an example on the web to reference a form within another form so that the properties can be used in the 2nd form. I have found a VB example (unfortunately i know nothing about VB) below but i have not been able to find a c# example.
The VB code in question is: -
Code:
Dim myForm As Form2
Private Sub Button1_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
If myForm Is Nothing Then
myForm = New Form2
myForm.myCaller = Me
End If
myForm.Show()
End Sub
I have a form that opens another form. The 2nd form then opens a 3rd form form etc. I need to be able to reference the first form within the 2nd form so that if i click on a back button it hides the 2nd form and re-opens the 1st form and then if i click next on the 1st form i need to be able to re-open the 2nd form.
Can anyone please help me?
Thanks.
Darren
-
March 10th, 2006, 04:53 PM
#2
Re: Navigating between multiple forms in C#
You could use the overloaded Show method for the Form object and pass "this" as owner, then you can find out with the second forms Owner property.
In form1:
Code:
Form2 f = new Form2();
f.Show(this);
In form2:
Code:
MessageBox.Show(this.Owner.ToString());
Maybe not the best way, but a way. 
/Leyan
Last edited by Athley; March 10th, 2006 at 04:55 PM.
-
March 10th, 2006, 04:57 PM
#3
Re: Navigating between multiple forms in C#
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|