7 Years
Discussion Span
Last Post by Diamonddrake

How can i copy from a treeview control to a text box or list box. Please help me soon.

Want to give us the code you have so far and some further explanation?


by "copy" do you simply mean take the text from the treeview (treeview? huh, title says listbox) and have it be displayed in a textbox or listbox.

Strings are Reference type, so "copying" the information is substantially more complicated than assigning a reference to the text property of a textbox.

but the short answer is textbox.text = treeview.SelectedNode.Text; The text property that all classes the inherit from the System.Windows.Forms.Control class contains whatever text is being displayed by that control. On a form, its the title caption, on a label its the display text, in a textbox its the text that's in it, and in the Node class that represents a member of a tree view its the text displayed on that node.

so you simple set the text property of the control you want to "copy" the text to with the text property of the control you want to "copy" the text from.

If you can't tell... I'm really bored right now... this is probably the simplest question I have ever seen on this forum... and normally silly questions like this one don't get answered. Because it will take you longer to read this long post than it would have to google it and find the answer.

for a free project to download with dozens of lines of source code try http://www.c-sharpcorner.com/uploadfile/scottlysle/treeviewbasics04152007195731pm/treeviewbasics.aspx

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.