Click here to Skip to main content
15,877,675 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am developing a windows application. Here I have 2 forms, named form1,form2.
In form 1 I have a treeview and label.

treeview Nodes. under root node all are the child nodes as shown below.

root
node1
node2
node3
if I select any child node the label text will become as selected node name.Like if I select node0, the label value will become nodeo. upto now it is ok.


now from form2 I want to get the value of label.but it is giving me empty value. I wrote below code.

form 1 ctrls=new form1();
textbox1.text=ctrls.label.text;

it is giving me empty value. plz help me I am new to c# and trying to learn.
Posted
Comments
BillWoodruff 7-Jan-14 9:14am    
You are asking virtually the same question you've asked before. Why haven't you learned anything from the previous answers ?
hussain548 7-Jan-14 9:47am    
yes sir, I got it sorry for bothering you

1 solution

Quote:
form 1 ctrls=new form1();
textbox1.text=ctrls.label.text;

Here you are creating a fresh new form1 (featuring, of course, the empty label) instead of using the original one. If a reference to the original form1 is available then use it. On the other hand, if it is not available then modify your code for passing such value to the second Form (for instance to its constructor) before closing form1.
 
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