Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello,
i create new desktop application in c#.
i have three windows forms , 1st form name- school details form
2nd form name - teacher details form
3rd form name - student details form

now in school details form i put 2 textbox for teacher name and teacher city and put 1 button near textbox.

now also school details form i put another 2 textbox for student name and student city and put 1 button near textbox.

now here when i click button teacher then open new form like 'teacher's details' in which only gridview and teachername and city display, now I use DataGridview Cell_Click event when i click on particular record it move to main School form.and this form close.

now same thing i do on another student form , on datagrid Cell_click event it move to school details page and selected data in textbox.

but problem is when i select 1st button click it display data , and when i click 2nd button it retrive data but 1st data remove automatically.

school load event occurs and selected data.
so how can i stop that.and pass data without load event.

What I have tried:

C#
hello,
i create new desktop application in c#.
i have three windows forms , 1st form name- school details form
                             2nd form name - teacher details form
                             3rd form name - student details form
  
now in school details form i put 2 textbox for teacher name and teacher city and put 1 button near textbox.

now also school details form i put another 2 textbox for student name and student city and put 1 button near textbox.

now here when i click button teacher then open new form like 'teacher's details' in which only gridview and teachername and city display, now I use DataGridview Cell_Click event when i click on particular record it move to main School form.and this form close.

now same thing i do on another student form , on datagrid Cell_click event it move to school details page and selected data in textbox.

but problem is when i select 1st button click it display data , and when i click 2nd button it retrive data but 1st data remove automatically.

school load event occurs and selected data.
so how can i stop that.and pass data without load event.
Posted
Updated 17-Nov-16 20:03pm
Comments
Er. Puneet Goel 18-Nov-16 1:07am    
This is too much of details also incomplete. Please conclude your issue in short with code.
Member 11952997 18-Nov-16 1:24am    
simple say form1 is main form, also pass four different textbox. and two buttons.
when click 1st button it open new form2, form2 have datagridview,and when click datagridview cell_click event it pass data in form1's 1st two textbox.
now in form1 another button click it open form3, and form3 have datagridview,and when click datagridview cell_click event it pass data in form1's 2nd two textbox.

problem is when retrive form3 's data in form1 then form2 data in form1 not display, load event remove old data.

1 solution

Use an temp table in Sql to save the temp data, then fetch it when required. Let me know if are getting the idea.
 
Share this answer
 
Comments
Member 11952997 18-Nov-16 2:07am    
how can it possible sir?
Er. Puneet Goel 18-Nov-16 3:16am    
In sql let table has no of columns as your form1 has.Now, when you click on form 2 put the data in table's respective column and display to form 1. Now when you open form 3 and click datagridview cell_click again copy data to sql table for fetch whole data back to form 1 from sql table. Thus you can maintain the previous data.

Going high leve: Create a class with static property and assign value.
here is the solution
http://stackoverflow.com/questions/14599127/session-for-windows-forms-application-in-c-sharp
Member 11952997 18-Nov-16 3:27am    
thank you s much, i am trying this
Er. Puneet Goel 18-Nov-16 3:29am    
welcome.

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