0

Well, Since I don't have the code here in this machine, I'm gonna try to be as clear as possible to explain what I have to do and hopefully get some help. Well, I'm doing a remote pagination (using remoting) and to show the files I'm using a treeview, but first I developed this treeview to make easier my filtering job: PatternComposite

Well, what I need to is, I have a comboBox with the extensions and when the user select between the values, the tree must be updated showing only the files with the selected(s) extension(s).

How can I do so ?

Edit:

After trying a lot, I was able to do the filtering stuff by repopulating the treeview using the searchPattern, but what I can't do now is save the expanded nodes before the repopulation. Let's say I have this tree:

-- C:

++ ProgramFiles
   -- Dell
-- EA
++ Google
   -- Dll
-- Whatever

Where the ++ are the expanded nodes. How can I have the same structure (the expanded nodes like the above) after repopulation ? Do I have to do a recursion expanding the nodes ?

Thanks again !

Leonardo
  • 3,141
  • 3
  • 31
  • 60
  • Are you asking about the filter or the combobox event? For the filter, filter your data in code and bind just the filtered data. For the event, use the SelectedIndexChanged event. – Amiram Korach Jul 26 '12 at 03:35
  • The filter, the comboBox is easy. What do you mean by bindig ? Thanks ! – Leonardo Jul 26 '12 at 10:49
  • Do you know how to populate the treeview with data? – Amiram Korach Jul 26 '12 at 10:53
  • Sure, I have done that yet. I just need to filter files by extension. – Leonardo Jul 26 '12 at 12:57
  • How do you get your file names? Can you filter your data and then populate the tree? – Amiram Korach Jul 26 '12 at 13:18
  • Yes, actually what I do is quite simple. I get each file and folder from treenodes (after its populated), using the fullpath (which gives me the phisical path), then I use Directories.GetFiles (or GetDirectories) and the search pattern using the value in the comboBox to filter the files. But the problems I face are: After filtering, I collapse all the treeview, call the populate function again (using the filter) but I can't "save" the previous location to open it after the search (to the user, he wouldn't realize another call has been made). Is it clear ? Thanks – Leonardo Jul 26 '12 at 13:36
  • Sorry but I didn't understand your problem. Try to rephrase your question with some code and more details. – Amiram Korach Jul 26 '12 at 13:38
  • Ok, sorry. I'm able now to filter by extension, but the last (I hope) problem I face is, how can I "save" the before-filter states (which folders were expanded, and then after repopulating (which clears the treeview) show it just like it was before. Got it ? Thanks ! – Leonardo Jul 26 '12 at 13:46
  • Hey @AmiramKorach, I have reedited, see if you understand ! Thanks ! – Leonardo Jul 26 '12 at 13:54
  • Thanks guys, I did it ! There is (adapted) the solution I found: http://www.dotnetspider.com/resources/4905-Search-Node-TreeView.aspx – Leonardo Jul 26 '12 at 18:10

1 Answers1

0

Now it is more clear. I think you assume that all nodes before repopulating stayed after that, but it is not always true. You can save somewhere the nodes keys with their current state before repopulating and go over them after that and set the previous state for nodes that stayed in the tree. Another option is not to repopulate at all but to put all nodes in the tree and just hide those that don't suit the filter.

Amiram Korach
  • 13,056
  • 3
  • 28
  • 30