|
Hello !
I have e vb.net project where m using a treeview.
I have a situation when for a specific node , I need the next or previous node , I mean according to position or order that each node has on the tree.
The existing properties NextnNode or PreviousNode , are not helping me because they are referring only to nodes inside a Nodes collection , and for example if the node is last child , NextNode return NULL.
I need general function for the entire Tree.
To be more clear :
For example :
N1
-N11
-N12
--N121
N2
-N21
-N22
In the above example , the Next node of N121 will be N2 , or the previous node of N2 will be N121. ( the tree may be full/partial collapsed or expanded )
Is there any property or function to do this ?
Thank you !
modified 14-Oct-16 19:45pm.
|
|
|
|
|
I think you misunderstand the node relationships. N121 does not have a next node, and the previous node of N2 is N1. If you want a different relationship tree then you would need to create it manually yourself.
|
|
|
|
|
I think you misunderstand what I wrote.
I know the node relationship , but I have a situation where I need to have Next and Previous working in that way.
So , since the actual existing Nextnode and Previousnode are not for this kind of situation , i need help te create new functions that works as i want.
|
|
|
|
|
No, I don't misunderstand. And, as I said in my previous message, if you want such a set of links, then you will need to create them yourself.
|
|
|
|
|
The TreeView contains a private nodeTable field that contains a hashtable with all the nodes. Instead of turning the tree into a list, it is advisable to learn to walk a tree. Do to do, you'll need recursion.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
There's nothing built-in, but it's fairly simple to write your own:
Public Shared Function FindNextNode(ByVal node As TreeNode) As TreeNode
If node Is Nothing Then Throw New ArgumentNullException("node")
If node.GetNodeCount(False) <> 0 Then
Return node.Nodes(0)
End If
While node IsNot Nothing
Dim nextNode As TreeNode = node.NextNode
If nextNode IsNot Nothing Then Return nextNode
node = node.Parent
End While
Return Nothing
End Function
Public Shared Function FindPreviousNode(ByVal node As TreeNode) As TreeNode
If node Is Nothing Then Throw New ArgumentNullException("node")
Dim result As TreeNode = node.PrevNode
If result Is Nothing Then
result = node.Parent
Else
Dim childCount As Integer = result.GetChildCount(False)
While childCount <> 0
result = result.Nodes(childCount - 1)
childCount = result.GetChildCount(False)
End While
End If
Return result
End Function
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Dear All,
Can you share a program using VB6 for access and post data web service?
Thanks
|
|
|
|
|
|
Google is your friend. Go there and type "vb6 post web service" and start reading. You'll find a bunch of examples.
|
|
|
|
|
Good afternoon All,
I want ask something about MySQL, I have a system that made by Visual Studio 2010 n MySQL. Everytime I ran that application, sometimes appear an error "Too Many Connections". How can i handle that error. Anyone can help me please..
Thx,
HR
|
|
|
|
|
Make sure you are closing your connections as soon as you have finished using them.
|
|
|
|
|
Dear Richard,
thanks for your suggestion. The Application can be run normally now.
regards,
Hermawan
|
|
|
|
|
Redesign your application so all your database requests/connections go through the single class.
Oh an close THE connection when you have finished with it!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Ok holmes, Its have been run normally now. Thanks for your suggestion.
|
|
|
|
|
How do I get a file in subfolder 3 levels down in UWP? It appears Microsoft wants a query to do this. I have this relative path under their applicationdata.localstate path: \archives\EvalResults2016\month here \day here\
The file in day folder is in this format monthdayitemname.csv I am retrieving from eBay or web service.
jeffery
|
|
|
|
|
Hi,
THIS IS NOT FOR .NET.
I need this in vbs, js and vba
I want to findout the path to the active user his pictures.
I know how the find the documents, desktop of favorites throu specialfolders but pictures is'nt in it
In google I didn't find anything usefull.
Jan
|
|
|
|
|
There is no enumeration to get to Pictures from VBA and VBScript. Pictures was never added to those old things.
Javascript in a browser has no access to the users filesystem so that's pretty much useless, unless you want to describe what you're doing with it.
The work around is to just use the path of "%USERPROFILE%\Pictures".
|
|
|
|
|
..that would be assuming a desktop with the English culture.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
indeed. This is not working for us
this is a working pc and all data folders are on a nas server.
thanks for the responses anyway.
maybee I can find it in the registry? but where?
Jan
|
|
|
|
|
Alternatively, you could ask the user for the location.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
For VBA, you'll need to use either SHGetFolderPath[^] or the newer SHGetKnownFolderPath[^].
How To Use the SHGetFolderPath Function from Visual Basic[^]
Option Explicit
Private Const S_OK = &H0
Private Const S_FALSE = &H1
Private Const E_INVALIDARG = &H80070057
Private Const MAX_PATH = 260
Private Const SHGFP_TYPE_CURRENT = 0
Private Const CSIDL_MYPICTURES = &H27
Private Declare Function SHGetFolderPath Lib "shfolder" _
Alias "SHGetFolderPathA" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, _
ByVal hToken As Long, ByVal dwFlags As Long, _
ByVal pszPath As String) As Long
Private Function GetFolderPath(ByVal csidl As Long) As String
Dim path As String
Dim returnValue As Long
path = String(MAX_PATH, 0)
returnValue = SHGetFolderPath(0, csidl, 0, SHGFP_TYPE_CURRENT, path)
Select Case returnValue
Case S_OK
GetFolderPath = Left(path, InStr(1, path, Chr(0)) - 1)
Case S_FALSE
GetFolderPath = vbNullString
Case E_INVALIDARG
Err.Raise 5, "csidl", "Invalid folder"
End Select
End Function
Public Function GetPicturesFolderPath() As String
GetPicturesFolderPath = GetFolderPath(CSIDL_MYPICTURES)
End Function
For script running locally, you could read the folder path from the registry (HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders). However, there is a warning in that key telling you not to do that!
Since you can't call Windows functions directly from script, you'd need to create a COM object to call the Windows API, and invoke that object from your script.
For script running in the browser, there is no way to access this information.
EDIT: There's also HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders , which doesn't have that warning. But the recommendation is still to use the Windows API.
In other words, the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 27-Sep-16 11:59am.
|
|
|
|
|
Richard Deeming wrote: However, there is a warning in that key telling you not to do that!
I thought you mistyped this until I went and looked at the key. No, you didn't. It's in there!
The path to Pictures is listed as "My Pictures", but like you said before, is this name localized? I have no idea.
|
|
|
|
|
I don't think the names would be localized, but I don't have a non-English version of Windows to check.
I've just added a link to a blog post from Raymond Chen, who explains that the "Shell Folders" key exists solely to permit four programs written in 1994 to continue running on the RTM version of Windows 95.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The names are localized. I got a folder "My Pictures", one called "Pictures" and one "Mijn Afbeeldingen". To make things worse, this does not say anything about the actual location, as my "Mijn Afbeeldingen" points to a completely different harddrive.
More on Wikipedia[^].
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I'd expect the names of the folders to be localized. But what about the names of the values in the "User Shell Folders" registry key?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|