Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 17th, 2008, 06:59 AM
Authorized User
 
Join Date: Feb 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Opening 1 form from another

Hi friends!! I m new to C# programming. I wanted to know how to open another from from one form while closing that form and not the application.

i.e. I have a login form, when login is successful then it should show MDI form and close the login form.

I m using this code but its not working

 private void but_loginok_Click(object sender, EventArgs e)
        {
            this.Close();
            MDIopeningpage mdi = new MDIopeningpage();
            mdi.Show();


JAININ
__________________
JAININ
 
Old February 17th, 2008, 09:17 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Shouldn't you close the form after opening the second form? Alternatively hide the first form and then open the second one.

--

Joe (Microsoft MVP - XML)
 
Old February 18th, 2008, 04:40 AM
Authorized User
 
Join Date: Feb 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually the problem is that i have a login form, and when the user clicks the submit button and if the username and password are same then the login form should close and the MDI for should open. I m not able to do this.

Can u help?

Thank You.
 
Old February 18th, 2008, 04:49 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Well if you close a form then it can't run code. So hide the form, open the new form and pass any details if needed and then close the opener.

--

Joe (Microsoft MVP - XML)
 
Old February 18th, 2008, 05:09 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

What Joe is trying to say is do this:

private void but_loginok_Click(object sender, EventArgs e)
{
     MDIopeningpage mdi = new MDIopeningpage();
     mdi.Show();

this.Close(); // move this to the end

}

/- Sam Judson : Wrox Technical Editor -/
 
Old February 18th, 2008, 07:31 AM
Authorized User
 
Join Date: Feb 2008
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you, I got it





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems while opening form anukagni Access 4 March 31st, 2008 05:54 AM
Form opening with filters ayazhoda Access VBA 2 August 22nd, 2007 03:58 AM
Opening a Form arholly Access 1 January 17th, 2007 11:59 AM
Closing a form after opening another form rosebushr Access 2 January 7th, 2006 04:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.