Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi For go to from2 form form1, I write following commands in a button on form1:

Form2 f = new Form2();
f.ShowDialog(this);

by when form2 will be open, I cant access to form1.
I want to access to both form in one time. Such as windows will be opened in windows operating system.


How can I do this?
Thanks very much
Posted
Comments
[no name] 8-Jun-13 5:52am    
Did you try f.Show(this)?
StM0n 8-Jun-13 6:19am    
Do want to just open the windows and change between them or do you want a list of all open forms?

Try
C#
Form2 f = new Form2();
f.Show(this);
However, if you want to pass information between them, have a look at these first:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
It's not difficult, but if you start off doing it right, it's a lot easier than adding it later!
 
Share this answer
 
You can use WPF's excellent Navigation panel just like as browser forward and backward button.You can navigate within your forms easily and you need not do much code for that.
You need to just call NavigationWindow like..
XML
<NavigationWindow x:Class="SGS.MainWindow2"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="SGS" Height="359" Width="587" Source="choicePage.xaml" WindowState="Maximized">

</NavigationWindow>

Where Source means that form what you need to show at startup your program.
See an example..
http://paulstovell.com/blog/wpf-navigation[^]
 
Share this answer
 
v3
C#
Form2 f = new Form2();
f.Show();



Hope it may help you.
 
Share this answer
 
Form2 f=new Form2();
f.ShowDialog(this)

in Form2 access Form1:
//code here
Form1 f1=f.Owner as Form1;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900