Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
I have a form where I have used tree view control to display File and folder browsed by user.
 
It displaying fine. I want that , if a user clicks on file , with new window contain all the tree-view nodes and state, means the selected node should be expanded, and selected file should be highlighted in the new form.
 
I am calling treefill(string path) method from outside of the class.
 
public string pTreePath { get { return strTreePath; } set { strTreePath = value; } }
 
How i can achieve this ?
Posted 28-Sep-12 6:27am
Edited 28-Sep-12 9:27am
(no name)8.6K
v2
Comments
Sergey Alexandrovich Kryukov at 28-Sep-12 13:24pm
   
I wonder why? If you already have some tree view, why having two? If you don't need two, why not just moving the original one? Why?
--SA
BillWoodruff at 28-Sep-12 20:21pm
   
Your description of exactly what you want to do is not specific enough for me to help you.
 
What exactly does "new instance of same Form" mean ?
 
Are you saying that when the user clicks on a node in the TreeView in one Form: you want to create another Form with a TreeView on it, and in that TreeView show the Node the user selected in the first TreeView as the "root node" in that TreeView fully expanded ?
 
If that's what you are saying, yes it can be done, but I'd ask you, just like Sergey did, why do you want to do it that way. What's your goal here ?
 
Do you only want to show in TreeView1 the nodes which have sub-nodes, but you don't want to all sub-nodes copied ?
arshad alam at 29-Sep-12 1:23am
   
My requirement to is that only, actually i am having a user control, that has a tree view control. when user clicks on the file in the tree view , it should open the new instance carrying all the data of tree view.
BillWoodruff at 29-Sep-12 1:35am
   
Hi Arshad,
 
"it should open the new instance"
 
In order to be helpful, I need to know exactly what you mean by "new Instance:" do you mean a new instance of the UserControl itself (to be placed within the same Form that contains the first UserControl), or: do you mean a new instance of the TreeView control to be placed within the same UserControl.
 
Is there a limit to how many instances you are going to create, whether the instances are a UserControl, or a TreeView ?
 
" carrying all the data of tree view."
 
The issue of copying over the "data" or "state" also needs clarification: you click on a Node with child Nodes in the first TreeView: and the Node you clicked on's child Nodes have "grand-child" Nodes: do you want to copy only the Child Nodes of the clicked-on Node ... without copying the "grandchildren" Nodes of the clicked on Node ... or: do you want to copy the whole structure that the clicked-on Node "contains" ?
 
Have you written recursive code in C# before that goes through every possible level of some hierarchic structure, like the ControlCollection of a Form, which may contain Panels within Panels, etc. ?
 
Have you experimented with the TreeNode.Clone() method exposed by WinForms ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,535
1 OriginalGriff 8,295
2 Peter Leow 4,839
3 Kornfeld Eliyahu Peter 3,210
4 Maciej Los 2,301


Advertise | Privacy | Mobile
Web02 | 2.8.150327.1 | Last Updated 28 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100