Anybody here work with Nodes is a TreeView?
I have a tree structure and need to enable editing to the selected Node. I have a String Variable where the enduser can Type in a new Folder name, click ok and the structure gets made. But I need the Node Name to follow suit.
The only way I know how to enable editing is:
and re-walk to make the template.Code:' Allow editing of the labels TemplateTreeview.LabelEdit = True
BUT - I have patient folders that need to be updated at the same time.
Needs to work with this code using GoodFolderName as new Node Name:
Code:Sub ChangeFolderName(ByVal BadLevel As String, ByVal GoodFolderName As String) 'BadLevel is the entire path of the folder with the end being what will get adjusted...EU putsd in data after Prog ''''' i.e. PDF_Archives$\MedicalRecords\#####\MH Adult\MH Adult\SECTION 1 - IDENTIFYING INFORMATION AND CONSENTS\CR251 Diagnostic Form ''''' This is the folder that gets a new name - CR251 Diagnostic Form Dim CheckThis As String Dim info As New System.IO.DirectoryInfo(myRootpath) Dim subDir As DirectoryInfo Dim BadFolderName As String Dim ProgCheck As String Dim Flag As Integer = 0 'Nod = TemplateTreeView.SelectedNode 'NewNod = New TreeNode(GoodFolderName) ' Allow editing of the labels TemplateTreeView.LabelEdit = True MessageBox.Show("Make your changes and click OK") 'Check to make sure folder exists in all instances (Chart Orders for program) 'Delete pre-existing file If File.Exists("Outbox\2818\EMR_ChangeCheck.txt") Then File.Delete("Outbox\2818\EMR_ChangeCheck.txt") End If Using sw As StreamWriter = New StreamWriter("Outbox\2818\EMR_ChangeCheck.txt", True) For Each subDir In info.GetDirectories PatientCB = subDir.ToString 'Program to check - WE ONLY CARE ABOUT CHANGING Structure if our Client is suppose to have that existing Chart order ProgCheck = myRootpath + PatientCB + SecLevel + Prog 'file path to check CheckThis = myRootpath + PatientCB + SecLevel + Prog + "\" + BadLevel If Directory.Exists(ProgCheck) Then ' set position to grab last folder name 'MessageBox.Show(CheckThis) If Not Directory.Exists(CheckThis) Then 'Make file path new directory 'MessageBox.Show("1") sw.WriteLine(PatientCB + " - Client doesn't have good Chart Order") End If End If Next 'close SW sw.Close() 'Grab file info of Errorlog... 0 means no data....2 in minimum empty file Dim a As IO.FileInfo = New IO.FileInfo("Outbox\2818\EMR_ChangeCheck.txt") 'MessageBox.Show(a.Length) If a.Length > 2 Then Flag = 0 MessageBox.Show("You must correct the following before Folders in this structure can be deleted. The Chart Order must be checked before proceeding.") 'Open notepad System.Diagnostics.Process.Start("notepad.exe", "Outbox\2818\EMR_ChangeCheck.txt") Exit Sub Else Flag = 1 End If End Using Flag = 1 BadFolderName = BadLevel If Flag = 1 Then Dim Ans As Integer Ans = MessageBox.Show("Do you want to change " + BadFolderName + " to " + GoodFolderName + " in your Chart Order?", "Delete Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) 'If yes then delete folderIf Flag = 1 Then If Ans = vbYes Then 'Loop through the patients For Each subDir In info.GetDirectories PatientCB = subDir.ToString 'reset checkthis just to get rid of error CheckThis = myRootpath + PatientCB + SecLevel + Prog + "\" + BadLevel If Directory.Exists(CheckThis) Then 'MsgBox(CheckThis) FileIO.FileSystem.RenameDirectory(CheckThis, GoodFolderName) End If Next MessageBox.Show("All Folders in the Chart Order for " + Prog + " have been changed from " + BadFolderName + " to " + GoodFolderName + ".") Else MessageBox.Show("You clicked no. The Folder - " + BadFolderName + " has NOT been renamed " + GoodFolderName + ".") Exit Sub End If End If End Sub




Reply With Quote