C# Tutorials and offshore development in India
Tutorials Resources Forum Reviews Communities Interview Jobs Projects Training Your Ad Here


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Code Snippets » Winforms Controls »

Open a new window by button click in parent form in winforms application


Posted Date: 09 Apr 2009    Resource Type: Code Snippets    Category: Winforms Controls
Author: Banshidhar SahooMember Level: Diamond    
Rating: 1 out of 5Points: 10



In one of my recent interviews, I was asked this question:
How can you Open a new window by button click in parent form in winforms application.

Please find the code for the same:


//Write this code in button click event of Form1
private void button1_Click(object sender, EventArgs e)
{
Form2 frmObj = new Form2();
frmObj.Show();
}


The above code will open a new window on button click and you can toggle between both parent window and this new window.

If you dont want to allow the user to toggel between parent window and new window, you can use below code.


//Write this code in button click event of Form1
private void button1_Click(object sender, EventArgs e)
{
Form2 frmObj = new Form2();
frmObj.ShowDialog();
}



Responses to the resource: "Open a new window by button click in parent form in winforms application"

No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Open new window  .  Form.ShowDialog()  .  Form.Show()  .  Winform new window  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Open File Dialog Box
Previous Resource: Save File Dialog Control
Return to Discussion Resource Index
Post New Resource
Category: Winforms Controls


Post resources and earn money!
 
More Resources




About Us    Contact Us    Privacy Policy    Terms Of Use