Click here to Skip to main content
12,701,087 members (30,102 online)

Visual Basic

 
GeneralRe: TreeView Find Starting from Some Child Node Pin
Eddy Vluggen14-May-13 10:10
mvpEddy Vluggen14-May-13 10:10 
GeneralRe: TreeView Find Starting from Some Child Node Pin
treddie14-May-13 12:53
membertreddie14-May-13 12:53 
QuestionStore sha passphrase in code Pin
frankelman11-May-13 3:33
memberfrankelman11-May-13 3:33 
AnswerRe: Store sha passphrase in code Pin
Garth J Lancaster11-May-13 3:54
memberGarth J Lancaster11-May-13 3:54 
GeneralRe: Store sha passphrase in code Pin
frankelman11-May-13 9:01
memberfrankelman11-May-13 9:01 
GeneralRe: Store sha passphrase in code Pin
Garth J Lancaster11-May-13 18:16
memberGarth J Lancaster11-May-13 18:16 
GeneralRe: Store sha passphrase in code Pin
frankelman12-May-13 3:22
memberfrankelman12-May-13 3:22 
QuestionConverting a string into a method Pin
treddie10-May-13 21:54
membertreddie10-May-13 21:54 
Hi again.

I have a peculiar problem that is somewhat reminiscent of vb6's Eval() function.

Let's say I have a TreeView populated with an entire harddrive's directory structure, and I want to select the node that contains a folder I am looking for. If I use the .Find method, the search could take forever, and I may end up with multiple places in the TreeView where this name is located. If I already have the full path to the correct folder, then I need a quick way to get to the node without having to search the entire tree.

Now, I actually have a quick way of doing this (at least I am confident it will work), but in the process of getting to that solution, I was experimenting with another idea that harks back to that vb6 Eval() function...Sort of. That other idea revolved around selectively expanding a tree branch and testing inside each child node to make sure that the next folder name in my full path could be found there. If so, it would expand that node and continue until all folders in the full path had been exhausted. Theoretically, I would then be at my desired node, which I could then select in the tree. But the problem is that in order to do that, you start at TreeView1.Nodes(0) and do a Find(). Once that node is selected, it gets expanded and you then do a Find() for the second folder, which gets found at Nodes(0).Nodes(x). Moving along in the same fashion, you get to Nodes(0).Nodes(x).Nodes(y), and so on till the task is completed. I think you can see the problem already...Without explicitly setting up Case blocks or If/Else blocks to handle each succession of methods,
Nodes(0)
Nodes(0).Nodes(x)
Nodes(0).Nodes(x).Nodes(y),...


there is no way for the code to handle this problem. And such a folder could lie at the tenth childnode, maybe even the twentieth, or more. The point being, it is a kludge to try to estimate when you should stop providing hard-coded cases and pray that some scenario doesn't exceed that limit.

That is when I was thinking if there was a way to build a string programatically to whatever length I needed it to be, like,
"TreeView1.Nodes(0).Nodes(x).Nodes(y).Expand"

and then convert that string into an actual code statement by having the string "evaluated" as such. Is this possible? As I stated above, I think I found another very elegant solution to my TreeView Find() problem which is simple and quick. But I am curious now, if vb.Net has the ability to turn a string into a code statement, or maybe even multiline text into actual vb.Net code?
AnswerRe: Converting a string into a method Pin
NeverJustHere11-May-13 1:04
memberNeverJustHere11-May-13 1:04 
GeneralRe: Converting a string into a method Pin
treddie11-May-13 18:05
membertreddie11-May-13 18:05 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak11-May-13 20:18
mvpDave Kreskowiak11-May-13 20:18 
GeneralRe: Converting a string into a method Pin
treddie11-May-13 22:36
membertreddie11-May-13 22:36 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak12-May-13 5:55
mvpDave Kreskowiak12-May-13 5:55 
GeneralRe: Converting a string into a method Pin
treddie13-May-13 12:13
membertreddie13-May-13 12:13 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak13-May-13 13:18
mvpDave Kreskowiak13-May-13 13:18 
GeneralRe: Converting a string into a method Pin
treddie13-May-13 14:06
membertreddie13-May-13 14:06 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak13-May-13 19:26
mvpDave Kreskowiak13-May-13 19:26 
GeneralRe: Converting a string into a method Pin
treddie14-May-13 20:34
membertreddie14-May-13 20:34 
GeneralRe: Converting a string into a method Pin
treddie11-May-13 22:42
membertreddie11-May-13 22:42 
AnswerRe: Converting a string into a method Pin
dusty_dex11-May-13 1:30
memberdusty_dex11-May-13 1:30 
GeneralRe: Converting a string into a method Pin
treddie11-May-13 18:07
membertreddie11-May-13 18:07 
GeneralRe: Converting a string into a method Pin
dusty_dex12-May-13 1:01
memberdusty_dex12-May-13 1:01 
GeneralRe: Converting a string into a method Pin
treddie12-May-13 1:44
membertreddie12-May-13 1:44 
GeneralRe: Converting a string into a method Pin
dusty_dex12-May-13 2:05
memberdusty_dex12-May-13 2:05 
GeneralRe: Converting a string into a method Pin
treddie13-May-13 11:13
membertreddie13-May-13 11:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.170118.1 | Last Updated 23 Jan 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid