Click here to Skip to main content
15,913,685 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have two window.
1. ListName
2. Student
I wanna to pass value from ListName to Student
List page Code:-
string str = (dgRecord.Columns[0].GetCellContent(row) as TextBlock).Text;
            Student student = new Student();
            student.Tbox.Text = str;
            DialogResult = true;

and My student page code is:-
I declare Tbox like
public TextBox Tbox = new TextBox();

adn code is:-
ListName frm = new ListName();
           frm.ShowDialog();
           if (frm.DialogResult.HasValue && frm.DialogResult.Value)
           {
               txtID.Text = Tbox.Text;
               txtID.Focus();
           }

txtID.text is null why ??
anybody can me tell.
Posted
Comments
Afzaal Ahmad Zeeshan 28-Feb-15 6:02am    
You can use the namespace of your project, and call members on different classes to get their values.
J{0}Y 28-Feb-15 6:20am    
why namespaces?? both are in same folder

1 solution

If they are separate forms, then you need to treat them as separate objects.

These are WinForms based examples, but the WPF system is the same:
Transferring information between two forms, Part 1: Parent to Child[^]
Transferring information between two forms, Part 2: Child to Parent[^]
Transferring information between two forms, Part 3: Child to Child[^]
So the techniques are the same, even if some of the controls are different.
 
Share this answer
 
Comments
J{0}Y 28-Feb-15 6:28am    
i am not use window form
OriginalGriff 28-Feb-15 6:43am    
I know that, that's why I said "So the techniques are the same, even if some of the controls are different."
J{0}Y 28-Feb-15 7:02am    
ohk i can try.but i have a doubt that is my code is wrong or it have a small Mistake??
OriginalGriff 28-Feb-15 7:15am    
It has lots of mistakes! :laugh:
Like accessing controls on a different form...

But you do realize that creating a new instance of anything does just that: create a new instance. It doesn't display it, or save it so you can fetch it later.
So when you say
Student student = new Student();
student.Tbox.Text = str;
DialogResult = true;
The only reference you have to the new student instance will be discarded at the end of the method?

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