Click here to Skip to main content
15,885,868 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have to pass a date to all forms from the login form. It shouldn't display on a form. any method to pass the value to all forms in c#, windows application?
Posted

This is the popular question about form collaboration. The most robust solution is implementation of an appropriate interface in form class and passing the interface reference instead of reference to a "whole instance" of a Form. Please see my past solution for more detail: How to copy all the items between listboxes in two forms[^].

Please see other answers to this question: How to copy all the items between listboxes in two forms[^].

Even though I think that my solution is the most comprehensive, you may prefer somewhat simpler ones, which could be adequate for simpler projects.

—SA
 
Share this answer
 
v2
If you want to pass the value to all form better add one static property at your program.cs

In Program.cs

C#
public static DateTime date
{
    get;
    set;
}
 
Share this answer
 
v2
Comments
Neha Thanka 31-Jul-12 22:30pm    
How will add the property at program.cs?
Renju Vinod 1-Aug-12 0:57am    
I have updated the solution
Neha Thanka 1-Aug-12 2:11am    
Thank you so much.....
 
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