Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello

i am a begginer to C#...i need help to develop my first application..
Posted

Create a property on the second form e set this property from the first form, then you show the second form.

Form2:
C#
public string Information
{get; set;}


Form1:
C#
Form2 f = new Form2();
f.Information = "bla bla bla"
f.Show();
 
Share this answer
 
This is a popular question of form collaboration. The most robust way is to implement appropriate interface in form class. Please see my past answer to this question: How to copy all the items between listboxes in two forms[^]; see other suggestions and the discussion.

—SA
 
Share this answer
 
Comments
Pravin Patil, Mumbai 24-Sep-11 1:38am    
My 5 for a better link...
Sergey Alexandrovich Kryukov 24-Sep-11 20:21pm    
Thank you, Pravin.
--SA
the best way is to create a global class and retrieve information from the database and store it in that class, and when any form needs that data it reads it from the global class
 
Share this answer
 
There are two ways to do so :
1. Use the constructor to take the value as input
2. Use the property

Check out :
1. Passing Data Between Forms[^]
2.http://colinmackay.co.uk/blog/2005/04/22/passing-values-between-forms-in-net/[^]
3. http://msdn.microsoft.com/en-us/magazine/cc164124.aspx[^]

Hope this helps.
All the best.
 
Share this answer
 
Comments
Uday P.Singh 23-Sep-11 13:26pm    
nice links my 5!
Pravin Patil, Mumbai 24-Sep-11 1:37am    
Thanks Uday..
Sergey Alexandrovich Kryukov 23-Sep-11 20:44pm    
Of course there are more, and those you list are not the most robust. I voted 4. Please see my solution.
--SA
Pravin Patil, Mumbai 24-Sep-11 1:37am    
I accept SA, your link is better than me..... Thanks for the vote anyway...
As the question turned out to be very popular, and my previous answers often were not well understood, probably were not clear enough, I decided to write a Tips/Trick article complete with detailed code samples and explanations: Many Questions Answered at Once — Collaboration between Windows Forms or WPF Windows.

—SA
 
Share this answer
 
Comments
King Fisher 23-Mar-15 2:09am    
Sorry ,I don't understand why are you posting the same solution for many questions?
Sergey Alexandrovich Kryukov 23-Mar-15 2:42am    
Not the same. And why not? It's done to help many beginners. I found that my usual answer to this very popular question is not very well understood and am trying to fix the situation. What could be unclear here?
—SA
King Fisher 23-Mar-15 2:55am    
Sir,But its a 4 year old question, you restarted the old thread in QA. When i was starter i answered very old questions ,so my post was marked as spam and got downvotes but the solution was right and one of your experts told me that if you restart the old thread it consider as spam.
Sergey Alexandrovich Kryukov 23-Mar-15 3:09am    
I have no idea about it. To best of my knowledge, there is no such concept as "restart of the thread". Maybe, this is the fantasy of that expert or expresses her/his own opinion. Who told you that?

Use you own logic: do you think that issues can have expiration time? The platforms I wrote about did not went out of support, the issue is actual. If someone wrote ugly code 4 years ago, won't it be helpful to know that it still can be fixed? This is exactly why I decided to write this article, to improve my past answers and provide better help.

I also got several down-votes on the answers like this one. As the reputation points of the person who did that are the same in all cases, it looks like this is the activity of some maniac obsessed with the similar idea about "old threads" or "boosting reputation points", envy and counter-productive. Why paying so much attention for that. When someone reported your post for spam on such ground, you could ask a question about such things at Bugs and Suggestions or maybe Spam and Abuse Watch forum...

Yes, massive down-votes can be done if someone is cheating, regularly posting misleading information of non-answers, fake answers (such as most self-answers) or articles; and plagiarism and spamming should lead to cancellation of the account. But counting who answered what questions, in how many posts, in case of valuable answers, is just misery.

—SA
King Fisher 23-Mar-15 3:24am    
I don't remember the name ,let me check my post and let you know. You know that nobody downvoted your solution because you have high reputation points but any body answered with low reputation points definitely will get downvotes by one of ours.I don't know why? does everyone common here or not?

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