473,606 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Ru n(...)", 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 1809
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.co m

"Renzo" <Re***@discussi ons.microsoft.c om> wrote in message
news:CD******** *************** ***********@mic rosoft.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.Ru n(...)", 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.co m

"Renzo" <Re***@discussi ons.microsoft.c om> wrote in message
news:CD******** *************** ***********@mic rosoft.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.Ru n(...)", 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
600
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 called MyFunction. Can you specify a string for the function name like you can with the form name? That is can I do something like Forms("MyForm")."MyFunction"
14
2989
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() ' This method shows the form used to get the info If sWhereInt = "" Then DoCmd.OpenForm sFormNameInt, acNormal, , , acFormAdd, _
2
6604
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 and Size properties before calling the Show method, the form is not created in the Location that I set. If I call Show first everything works fine but there is excesive flicker when the Location and Size properties are set. I tried calling...
6
1695
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, but I want to put the function's code in an external file, so that future updates to the function will require a replacing the function file instead of re-installing the whole project. Can you give me ideas on how I can make small updates to my...
0
2378
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 button called "cmdFilter" which retrieves data from the database using any criteria thus selected. For any of the records retrieved into the grid match certain conditions, one of the columns will be formed into a hyperlink. Clicking on this will...
3
3569
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 and then do a refresh of the calling form. Any ideas on how to get a reference to the calling form? I tried window.parent.location.reload() , but it doesn't work. Thanks a lot.
7
2936
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: Application.Run(new Form1()); was okay, but this: Form1 form = new Form1();
1
1742
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 Invoke, I declared a delegate to handle the cross-thread call to bring the form forward. Here's my code: Delegate Sub BringMeFront() Public myDelBringFormFront As BringMeFront
0
7939
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8078
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6753
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5456
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3964
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.