473,404 Members | 2,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

calling a form from a form

hi ! i've recently begun developing in c# and i'd like to know what's the
best way of calling a form from an already instanced form ? I have done a
"Login" form which I run in the Main() using "Application.Run(...)", now when
the user logins correctly, another form named "Calendar" must be called. How
can I do this ? Should I close the first form first and then instance the
new one or how ? Thanks.
Nov 17 '05 #1
2 1802
Renzo,

My preference is to have two application loops, like so:

// Show the login form.
Application.Run(new LoginForm());

// Show the Calendar form.
Application.Run(new CalendarForm());

If you need access to the variables, you could do something like:

// The login form.
LoginForm lf = new LoginForm();

// Show the login form.
Application.Run(lf);

// The calendar form. Initialize with login form to get access to it.
CalendarForm cf = new CalendarForm(lf);

// Show the form.
Application.Run(cf);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Renzo" <Re***@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.com...
hi ! i've recently begun developing in c# and i'd like to know what's the
best way of calling a form from an already instanced form ? I have done a
"Login" form which I run in the Main() using "Application.Run(...)", now
when
the user logins correctly, another form named "Calendar" must be called.
How
can I do this ? Should I close the first form first and then instance the
new one or how ? Thanks.

Nov 17 '05 #2
Thanks Nicholas. I will do it that way too. Currently, I was calling it
from the frmLogin using ShowDialog() but this means that the previous form is
still loaded. I was using Hide() to make it dissappear but I feel it was not
the correct way. I prefer your method.

Cheers.

"Nicholas Paldino [.NET/C# MVP]" wrote:
Renzo,

My preference is to have two application loops, like so:

// Show the login form.
Application.Run(new LoginForm());

// Show the Calendar form.
Application.Run(new CalendarForm());

If you need access to the variables, you could do something like:

// The login form.
LoginForm lf = new LoginForm();

// Show the login form.
Application.Run(lf);

// The calendar form. Initialize with login form to get access to it.
CalendarForm cf = new CalendarForm(lf);

// Show the form.
Application.Run(cf);

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Renzo" <Re***@discussions.microsoft.com> wrote in message
news:CD**********************************@microsof t.com...
hi ! i've recently begun developing in c# and i'd like to know what's the
best way of calling a form from an already instanced form ? I have done a
"Login" form which I run in the Main() using "Application.Run(...)", now
when
the user logins correctly, another form named "Calendar" must be called.
How
can I do this ? Should I close the first form first and then instance the
new one or how ? Thanks.


Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: headware | last post by:
I know that you can call the method of one from from inside another form by doing something like this Forms("MyForm").MyFunction(12, 34) However, you have to know that MyForm has a function...
14
by: ericellsworth | last post by:
Hi, I'm trying to use a class to pass variables back and forth from a form opened in dialog mode. I have created a class which invokes a form in its show method, like so: Public Sub Show() '...
2
by: mark | last post by:
I am developing an application in .Net C# that needs to restore a number of tool windows to some previous location and size. The problem I have is that when I create the form and set the Location...
6
by: Amjad | last post by:
Hi, I want to make a project that calls and executes a function (VB code) made in a seperate file in the Application Folder. I know I can create the function in my project and call it internally,...
0
by: teddysnips | last post by:
I have Search form that allows users to retrieve records into a DataGrid. There are two search criteria - a Month and a Year, which are selected from drop-down lists. There is a server-side...
3
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup...
7
by: Lee Crabtree | last post by:
I remember when I was first getting into .NET Forms programming that there was a rather emphatic rule about not constructing a form before calling Application.Run with it. So this: ...
1
by: SAL | last post by:
Hello, I'm developing this remoting app (.net 2.0) and I need to bring the server app's form to the front often. Since you can not do cross-thread communication on a form or control without using...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.