Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
if i update some data then i want them to show immidietly by recalling constructor of the form
Posted
Comments
PrakashCs.net 2-Jul-14 1:29am    
recreate instance of that class .
Sergey Alexandrovich Kryukov 2-Jul-14 1:33am    
Not clear. Why "recalling" constructor? Who told you it can update anything?
—SA
Member 10491269 2-Jul-14 1:46am    
i have a form with some data feelings,and other form with a list view
when i submit button ,then data is saved in database and these data should be displayed in list view other form
Sergey Alexandrovich Kryukov 2-Jul-14 2:15am    
You thought about constructor makes no sense at all. If you need to display some data, display it. I have no idea what prevents you from doing it.
—SA
Member 10491269 2-Jul-14 1:50am    
so i need a reload concept to reload constructor

Think about the word 'constructor' - it implies the building our creation of an item, which you only do once for any item. If you are making a sandwich, you 'construct' it once, and 'use' it repeatedly for each bite.
If you constructed the sandwich each time you wanted a bite, you would get through a whole load in no time!

So forget constructors, and reuse the existing form by passing the new information to it and getting it to display you new data.
Have a look at this: Transferring information between two forms, Part 1: Parent to Child[^] it should help.
 
Share this answer
 
Comments
Rahul VB 2-Jul-14 14:52pm    
I will say high 5 instead of my 5. Great one.
Please see my comments to the question. It could be just 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 also see other solutions in this discussion. If the application is simple enough, the solution could be as simple as declaring of some internal property in one form and passing a reference to the instance of one form to the instance of another form. For more complex projects, such violation of strictly encapsulated style and loose coupling could add up the the accidental complexity of the code and invite mistakes, so the well-encapsulated solution would be preferable.

Please see also:
http://en.wikipedia.org/wiki/Accidental_complexity[^],
http://en.wikipedia.org/wiki/Loose_coupling[^].

—SA
 
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