|
Bummer.
I'm so close to finishing a program I've been working on for a year and the only thing hanging me up is this damn TreeView problem. I just find it so bizarre that MS could not provide some very simple functionality to a TreeView, that I would think would be self-evidently obvious properties and methods to include straight-away. I come up with nifty solutions only to have them dashed by a lack of really basic control methods. So frustrating.
|
|
|
|
|
Just because it's a "simple" method to make your job easier, doesn't mean it's a good thing to put into the framework.
The .NET Framework is already too heavy. That's why it has been split into Full and Client Profile versions. Why put more stuff into it that's really not neccessary?
|
|
|
|
|
Only because it has such far reaching and useful consequences. I doubt that .Net will cease to grow and get even more heavy, but this option would serve so many uses where recursion is not an option.
|
|
|
|
|
Not so useful. Actually, pretty limiting in both security and performance.
First, it's poor-performing code as it has to be compiled before use, at runtime. Access to variables might also have to be done through reflection as you REALLY don't want to run this code in the same AppDomain as the application code because of HUGE security problems with running user-enterable code in an app. Google for "SQL Injection attacks" for examples on how bad this is. The compile-time compiler also cannot possibly predict the contents of a string so it cannot pre-compile anything, wasting more time. You MIGHT get away with a caching scheme to improve performance a little bit, kind of like how strings are stored, but again, you'd have to be able to store the string with the compiled code so you have a quick lookup of the string version of the code as a key.
Oh, and you also lose type-safety and Intellisense.
If you think you need to do this in your application code, it's generally taken as a sign your code design is DEEPLY flawed.
|
|
|
|
|
Good points. So the emphasis is back to the limitations of the .Nodes() property. What a shame they did not set it up as, for example, TreeView1.Nodes(NodesArray(x)).SelectedNode. That would be a perfect road map for the Nodes property to follow, to get to a destination in the tree.
|
|
|
|
|
That doesn't make sense either as you'd have to manually walk the tree to find the node that is selected. Not very efficient, is it??
The TreeView already has a SelectedNode property which will return the node that is selected. From there, it's trivial to navigate up to the Node tree to the root of the Nodes collection in the TreeView control.
Getting back to your original search problem, you're going about it wrong. You're thinking about searching a tree structure that's not designed to be searched efficiently.
What you should be doing is a dedicated indexing solution for a collection of paths, each of which contains a reference to the Node it came from. Searching the dedicated structure would be far more efficient then searching the TreeView Nodes collection.
|
|
|
|
|
TnTinMn offered the following solution back in post, 13 May '13 - 13:13. Seems pretty darn elegant and compact. I am in the process of testing its performance on a TreeView loaded with a huge drive's directory structure.
|
|
|
|
|
NeverJustHere wrote: Something like: Find( CurrentNode, SubPath ) where the CurrentNode and SubPath are adjusted on each call to itself.
That is easy in principle, but it does not appear that there is any way to tell vb.Net to restrict a Find() to a starting childnode and a sub path. Without that, recursion is useless. Unless I keep building a new node structure that omits the prior part already searched. If that node structure represents an entire harddrive, that would be slower than watching mountains grow.
|
|
|
|
|
|
dusty_dex wrote: Is this^ any help?
Hi Dusty_dex. Are you referring to the previous post? If so, I'm checking into it.
But I am still curious about my original question...Has someone found a way to turn text into code? In general, it would be so cool and useful for so many things.
|
|
|
|
|
treddie wrote: But I am still curious about my original question...Has someone found a way to turn text into code?
66-666-##-11-22-88-8-##-999-666-88-##-222-2-66-##-4-33-88-##-7777-666-6-33-##-444-66-8-33-777-33-7777-8-444-66-4-##444-3-33-2-7777-11111
|
|
|
|
|
Lol! OK, Mr. Blechley Park!
|
|
|
|
|
If you're curious about recursive functions/parsing/codifying information, perhaps you should read this book: Godel, Escher & Bach by Douglas E. Hofstadter.
also, A New Kind of Science by Stephen Wolfram is pretty interesting too.
|
|
|
|
|
DoH! More book reading for my schedule! I'll have to look those up. Thanks!
|
|
|
|
|
Also take look at Emil Post's stuff on 'productions', circa 1930s.
The authors initial was wrong, it's Douglas R. Hofstadter. I need better glasses.
The NKS book is more along the lines of cellular automata. You might want to get the legs on your coffee table reinforced first.
|
|
|
|
|
|
treddie wrote: 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?
There's various ways to compile code (from your app) and execute it. I don't think it'd be very helpful in finding a TreeNode though.
treddie wrote: 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.
Start at the left of the folder-string. Find the item in the root-node. Open that node. Find the second part of the path in the current node's children. Repeat until the path is empty.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
That is where the frustration is. There is no way to set any ARBITRARY node as a "current" node and start the search from there, in a Find() method. Although you can restrict the search to a node and none of its children, you can't programmatically start a search at any node without it being specific. There is no general statement for:
= MyNodes(2).Nodes.Find("Hello", True)
and
= MyNodes(2).My1stChildNodes(3).Nodes.Find("Hello", True)
|
|
|
|
|
treddie wrote: There is no way to set any ARBITRARY node as a "current" node and start the search from there, in a Find() method
Ano node contains a node-collection that can be searched. If you know what node to start from, that is.
treddie wrote: There is no general statement for:
TreeView1.Nodes.Add("Node1", "Node1").Nodes.Add("Sub1", "Sub1").Nodes.Add("Hello", "Hello")
TreeView1.Nodes.Add("Node2", "Node2").Nodes.Add("Sub1", "Sub1").Nodes.Add("Hello", "Hello")
Dim foundNode As TreeNode = TreeView1.Nodes("Node2").Nodes("Sub1")
If foundNode IsNot Nothing Then
TreeView1.SelectedNode = foundNode
TreeView1.Focus()
End If
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: Ano node contains a node-collection that can be searched. If you know what node to start from, that is.
Eddy, is that a product?...The only thing I found was a site called "Ano Node", a freenet help site.
|
|
|
|
|
That should have been "A node contains a Nodes collection...".
|
|
|
|
|
Lol! Reminds me of the commercial where the guy is one question behind, due to buffering.
|
|
|
|
|
If the user is going to change large parts of the code,
use a ScriptControl COM component. It allows you to run a String as code.
|
|
|
|
|
Thanks, Edward! I'll check into it and report back.
|
|
|
|
|
Hello guys,
I'm creating an windows application using vb.net 2010 with mySQL as my database. My question is, if i deploy my application to another computer do i need to install too mySQL program? Thanks
@athan_MaKuBex13
|
|
|
|