Click here to Skip to main content
15,894,017 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: TryParse String from InputBox to Integer Pin
PIEBALDconsult13-May-13 17:30
mvePIEBALDconsult13-May-13 17:30 
QuestionHow to get values from listview and display it to textbox using sql database ? Pin
Member 1001708312-May-13 4:58
professionalMember 1001708312-May-13 4:58 
AnswerRe: How to get values from listview and display it to textbox using sql database ? Pin
Eddy Vluggen13-May-13 7:23
professionalEddy Vluggen13-May-13 7:23 
QuestionTreeView Find Starting from Some Child Node Pin
treddie11-May-13 21:20
treddie11-May-13 21:20 
AnswerRe: TreeView Find Starting from Some Child Node Pin
Eddy Vluggen11-May-13 22:18
professionalEddy Vluggen11-May-13 22:18 
GeneralRe: TreeView Find Starting from Some Child Node Pin
treddie11-May-13 23:50
treddie11-May-13 23:50 
GeneralRe: TreeView Find Starting from Some Child Node Pin
Eddy Vluggen12-May-13 1:16
professionalEddy Vluggen12-May-13 1:16 
GeneralRe: TreeView Find Starting from Some Child Node Pin
treddie13-May-13 11:04
treddie13-May-13 11:04 
The basic problem is this. In vb6 (and the COM controls as they were carried over into .Net), you have Dir and File List boxes. You could double-click a folder or file name and do something with it. You can do the same thing with a TreeView. The problem starts when you want to save out those selections when you close the program, so that when you come back, the Treeview has the old selections intact. That was no problem with a Dir or file Listbox, because you could simply set the boxes to a desired path name.

The question that comes up might be, "Well, why not stick to using Dir and File ListBoxes, then?" I wanted to do just that to simplify my port-over to vb.Net, and that would have been fine...If not for the fact that Dir/File Listboxes cannot pass the MAX_PATH = 260 barrier. Another problem in vb6, is that the ListBoxes are not Unicode compatible. But even though they are in .Net, the MAX_PATH barrier is still insurmountable.

So, the TreeView is the "only" answer. But there is no way to tell a TreeView to select a given node based either on a fullpath (there is no option for this), or to tell it to go to a particular node index or node handle. The only option is to store the node sequence (like, "1, 3, 2, 7") and count how many child nodes that translates into (4), then go to a sub or function that explicitly utilizes that same amount of nodes, (Nodes(1).Nodes(3),Nodes(2).Nodes(7)) in one or more methods. Now, in my 1/2 hour quick check of folder depths on my c:\ drive, I counted a maximum folder depth of 12, so it could easily be over that amount. That means, bare minimum, I would need 12 separate subs (These are quicky examples, and not debugged):
VB
Private Sub 1Node (ByVal ChildNodes() as Integer)
  TreeView1.SelectedNode = TreeView1.Nodes(x)
  TreeView1.SelectedNode.Expand()
End Sub

Private Sub 2Nodes (ByVal ChildNodes() as Integer)
  TreeView1.SelectedNode = TreeView1.Nodes(x).Nodes(y)
  TreeView1.SelectedNode.Expand()
End Sub

Private Sub 3Nodes (ByVal ChildNodes() as Integer)
  TreeView1.SelectedNode = TreeView1.Nodes(x).Nodes(y).Nodes(z)
  TreeView1.SelectedNode.Expand()
End Sub


And on and on for at LEAST 12 subs. Now, you just know many people will have folder depths much larger than that (And my drives might, too), so where do you stop? 20 subs? 30 subs? 100 Subs?! I would think to be on the safe side and throwing in a safety factor of 3, a bare minimum of 60 Subs. That is hardly elegant, but if that is what I need to do, then that is just the way it is.

I have noticed a very irritating side-effect of all this...Whenever I have a commercial program that uses a TreeView to navigate a media, it never remembers your last selections. So you have to go back every time and reselect everything. Now I know why. So, it was someone here who had made the comment with reference to another thread that has a bearing on this, and I respectfully paraphrase, "...You don't really need that abilty." I NEED IT! Smile | :) . And I have noticed a fair number of other threads on different sites where this problem comes up with no solution. Vb.Net's quantity of properties may be on the heavy side, but the way I look at it, this is one that just really needs to be added, maybe as an overload.
GeneralRe: TreeView Find Starting from Some Child Node Pin
TnTinMn13-May-13 15:13
TnTinMn13-May-13 15:13 
GeneralRe: TreeView Find Starting from Some Child Node Pin
treddie13-May-13 18:24
treddie13-May-13 18:24 
GeneralRe: TreeView Find Starting from Some Child Node Pin
Eddy Vluggen14-May-13 9:10
professionalEddy Vluggen14-May-13 9:10 
GeneralRe: TreeView Find Starting from Some Child Node Pin
treddie14-May-13 11:53
treddie14-May-13 11:53 
QuestionStore sha passphrase in code Pin
frankelman11-May-13 2:33
frankelman11-May-13 2:33 
AnswerRe: Store sha passphrase in code Pin
Garth J Lancaster11-May-13 2:54
professionalGarth J Lancaster11-May-13 2:54 
GeneralRe: Store sha passphrase in code Pin
frankelman11-May-13 8:01
frankelman11-May-13 8:01 
GeneralRe: Store sha passphrase in code Pin
Garth J Lancaster11-May-13 17:16
professionalGarth J Lancaster11-May-13 17:16 
GeneralRe: Store sha passphrase in code Pin
frankelman12-May-13 2:22
frankelman12-May-13 2:22 
QuestionConverting a string into a method Pin
treddie10-May-13 20:54
treddie10-May-13 20:54 
AnswerRe: Converting a string into a method Pin
NeverJustHere11-May-13 0:04
NeverJustHere11-May-13 0:04 
GeneralRe: Converting a string into a method Pin
treddie11-May-13 17:05
treddie11-May-13 17:05 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak11-May-13 19:18
mveDave Kreskowiak11-May-13 19:18 
GeneralRe: Converting a string into a method Pin
treddie11-May-13 21:36
treddie11-May-13 21:36 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak12-May-13 4:55
mveDave Kreskowiak12-May-13 4:55 
GeneralRe: Converting a string into a method Pin
treddie13-May-13 11:13
treddie13-May-13 11:13 
GeneralRe: Converting a string into a method Pin
Dave Kreskowiak13-May-13 12:18
mveDave Kreskowiak13-May-13 12:18 

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.