none
Drag and Drop a folder between TreeView1 RRS feed

  • Question

  • hi

    Drag and Drop a folder between TreeView1

    by select from TreeView1 and copy to TreeView2

    Monday, September 24, 2018 6:36 AM

Answers

  • You can use INameSpaceTreeControl which embeds Explorer TreeView and handles everything automatically

    A sample (I created them inside Picture Boxes, but you can also create them as child of the main form) =>

    Option Strict On
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Public Enum HRESULT As Integer
            S_OK = 0
            S_FALSE = 1
            E_NOINTERFACE = &H80004002
            E_NOTIMPL = &H80004001
            E_FAIL = &H80004005
        End Enum
    
        <StructLayout(LayoutKind.Sequential)>
        Public Structure RECT
            Public Left As Integer
            Public Top As Integer
            Public Right As Integer
            Public Bottom As Integer
        End Structure
    
        Public Enum NSTCSTYLE As Integer
            NSTCS_HASEXPANDOS = &H1
            NSTCS_HASLINES = &H2
            NSTCS_SINGLECLICKEXPAND = &H4
            NSTCS_FULLROWSELECT = &H8
            NSTCS_SPRINGEXPAND = &H10
            NSTCS_HORIZONTALSCROLL = &H20
            NSTCS_ROOTHASEXPANDO = &H40
            NSTCS_SHOWSELECTIONALWAYS = &H80
            NSTCS_NOINFOTIP = &H200
            NSTCS_EVENHEIGHT = &H400
            NSTCS_NOREPLACEOPEN = &H800
            NSTCS_DISABLEDRAGDROP = &H1000
            NSTCS_NOORDERSTREAM = &H2000
            NSTCS_RICHTOOLTIP = &H4000
            NSTCS_BORDER = &H8000
            NSTCS_NOEDITLABELS = &H10000
            NSTCS_TABSTOP = &H20000
            NSTCS_FAVORITESMODE = &H80000
            NSTCS_AUTOHSCROLL = &H100000
            NSTCS_FADEINOUTEXPANDOS = &H200000
            NSTCS_EMPTYTEXT = &H400000
            NSTCS_CHECKBOXES = &H800000
            NSTCS_PARTIALCHECKBOXES = &H1000000
            NSTCS_EXCLUSIONCHECKBOXES = &H2000000
            NSTCS_DIMMEDCHECKBOXES = &H4000000
            NSTCS_NOINDENTCHECKS = &H8000000
            NSTCS_ALLOWJUNCTIONS = &H10000000
            NSTCS_SHOWTABSBUTTON = &H20000000
            NSTCS_SHOWDELETEBUTTON = &H40000000
            NSTCS_SHOWREFRESHBUTTON = &H80000000
        End Enum
    
        Public Enum SHCONTF As Integer
            SHCONTF_CHECKING_FOR_CHILDREN = &H10
            SHCONTF_FOLDERS = &H20
            SHCONTF_NONFOLDERS = &H40
            SHCONTF_INCLUDEHIDDEN = &H80
            SHCONTF_INIT_ON_FIRST_NEXT = &H100
            SHCONTF_NETPRINTERSRCH = &H200
            SHCONTF_SHAREABLE = &H400
            SHCONTF_STORAGE = &H800
            SHCONTF_NAVIGATION_ENUM = &H1000
            SHCONTF_FASTITEMS = &H2000
            SHCONTF_FLATLIST = &H4000
            SHCONTF_ENABLE_ASYNC = &H8000
            SHCONTF_INCLUDESUPERHIDDEN = &H10000
        End Enum
        Public Enum NSTCROOTSTYLE As Integer
            NSTCRS_VISIBLE = 0
            NSTCRS_HIDDEN = &H1
            NSTCRS_EXPANDED = &H2
        End Enum
        Public Enum NSTCITEMSTATE As Integer
            NSTCIS_NONE = 0
            NSTCIS_SELECTED = &H1
            NSTCIS_EXPANDED = &H2
            NSTCIS_BOLD = &H4
            NSTCIS_DISABLED = &H8
            NSTCIS_SELECTEDNOEXPAND = &H10
        End Enum
    
        Public Enum NSTCGNI As Integer
            NSTCGNI_NEXT = 0
            NSTCGNI_NEXTVISIBLE = 1
            NSTCGNI_PREV = 2
            NSTCGNI_PREVVISIBLE = 3
            NSTCGNI_PARENT = 4
            NSTCGNI_CHILD = 5
            NSTCGNI_FIRSTVISIBLE = 6
            NSTCGNI_LASTVISIBLE = 7
        End Enum
    
    
        <ComImport>
        <Guid("028212A3-B627-47e9-8856-C14265554E4F")>
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        Public Interface INameSpaceTreeControl
            Function Initialize(hwndParent As IntPtr, ByRef prc As RECT, nsctsFlags As NSTCSTYLE) As HRESULT
            Function TreeAdvise(punk As IntPtr, ByVal pdwCookie As Integer) As HRESULT
            Function TreeUnadvise(pdwCookie As Integer) As HRESULT
            Function AppendRoot(psiRoot As IntPtr, grfEnumFlags As SHCONTF, grfRootStyle As NSTCROOTSTYLE, pif As IntPtr) As HRESULT
            Function InsertRoot(iIndex As Integer, psiRoot As IntPtr, grfEnumFlags As SHCONTF, grfRootStyle As NSTCROOTSTYLE, pif As IntPtr) As HRESULT
            Function RemoveRoot(psiRoot As IntPtr) As HRESULT
            Function RemoveAllRoots() As HRESULT
            Function GetRootItems(ByVal ppsiaRootItems As IntPtr) As HRESULT
            Function SetItemState(psi As IntPtr, nstcisMask As NSTCITEMSTATE, nstcisFlags As NSTCITEMSTATE) As HRESULT
            Function GetItemState(psi As IntPtr, nstcisMask As NSTCITEMSTATE, ByVal pnstcisFlags As NSTCITEMSTATE) As HRESULT
            Function GetSelectedItems(ByVal psiaItems As IntPtr) As HRESULT
            Function GetItemCustomState(psi As IntPtr, ByVal piStateNumber As Integer) As HRESULT
            Function SetItemCustomState(psi As IntPtr, iStateNumber As Integer) As HRESULT
            Function EnsureItemVisible(psi As IntPtr) As HRESULT
            Function SetTheme(pszTheme As String) As HRESULT
            Function GetNextItem(psi As IntPtr, nstcgi As NSTCGNI, ByVal ppsiNext As IntPtr) As HRESULT
            Function HitTest(ppt As Point, nstcgi As NSTCGNI, ByVal ppsiOut As IntPtr) As HRESULT
            Function GetItemRect(psi As IntPtr, ByRef prect As RECT) As HRESULT
            Function CollapseAll() As HRESULT
        End Interface
    
        Public CSIDL_DESKTOP As Integer = 0
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function SHGetFolderLocation(ByVal hwndOwner As IntPtr, ByVal nFolder As Integer, ByVal hToken As IntPtr, ByVal dwReserved As UInteger, <Out> ByRef ppidl As IntPtr) As HRESULT
        End Function
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function SHCreateItemFromIDList(ByVal pidl As IntPtr, <[In], MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, <Out> ByRef ppv As IntPtr) As HRESULT
        End Function
    
        <DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function MoveWindow(hWnd As IntPtr, X As Integer, Y As Integer, nWidth As Integer, nHeight As Integer, bRepaint As Boolean) As Boolean
        End Function
    
        <DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function FindWindowEx(ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
        End Function
    
        <DllImport("Ole32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function OleInitialize(pvReserved As IntPtr) As HRESULT
        End Function
    
        Dim pNameSpaceTreeControl, pNameSpaceTreeControl2 As INameSpaceTreeControl
    
        Friend WithEvents PictureBox1, PictureBox2 As PictureBox
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Me.PictureBox1 = New PictureBox()
            Me.PictureBox1.Location = New System.Drawing.Point(20, 20)
            Me.PictureBox1.Name = "PictureBox1"
            Me.PictureBox1.Size = New System.Drawing.Size(300, 400)
            Me.PictureBox1.TabIndex = 0
            Me.PictureBox1.TabStop = False
            Me.PictureBox1.BorderStyle = BorderStyle.FixedSingle
            Me.Controls.Add(Me.PictureBox1)
    
            Me.PictureBox2 = New PictureBox()
            Me.PictureBox2.Location = New System.Drawing.Point(340, 20)
            Me.PictureBox2.Name = "PictureBox2"
            Me.PictureBox2.Size = New System.Drawing.Size(300, 400)
            Me.PictureBox2.TabIndex = 1
            Me.PictureBox2.TabStop = False
            Me.PictureBox2.BorderStyle = BorderStyle.FixedSingle
            Me.Controls.Add(Me.PictureBox2)
    
            OleInitialize(IntPtr.Zero)
            Dim CLSID_NamespaceTreeControl As New Guid("AE054212-3535-4430-83ED-D501AA6680E6")
            Dim NameSpaceTreeControlType As Type = Type.GetTypeFromCLSID(CLSID_NamespaceTreeControl, True)
            Dim NameSpaceTreeControl As Object = Activator.CreateInstance(NameSpaceTreeControlType)
            pNameSpaceTreeControl = DirectCast(NameSpaceTreeControl, INameSpaceTreeControl)
            Dim hr As HRESULT = pNameSpaceTreeControl.Initialize(PictureBox1.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS Or NSTCSTYLE.NSTCS_HASLINES)
            If (hr = HRESULT.S_OK) Then
                Dim pidl As IntPtr = IntPtr.Zero
                hr = SHGetFolderLocation(IntPtr.Zero, CSIDL_DESKTOP, IntPtr.Zero, 0, pidl)
                If (hr = HRESULT.S_OK) Then
                    Dim psi As IntPtr = IntPtr.Zero
                    Dim GUID_IShellItem As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
                    hr = SHCreateItemFromIDList(pidl, GUID_IShellItem, psi)
                    If (hr = HRESULT.S_OK) Then
                        hr = pNameSpaceTreeControl.AppendRoot(psi, SHCONTF.SHCONTF_FOLDERS Or SHCONTF.SHCONTF_NONFOLDERS, NSTCROOTSTYLE.NSTCRS_EXPANDED, IntPtr.Zero)
                        If (hr = HRESULT.S_OK) Then
                        End If
                    End If
                End If
            End If
            Dim hWndTree As IntPtr = FindWindowEx(PictureBox1.Handle, IntPtr.Zero, "NameSpaceTreeControl", Nothing)
            MoveWindow(hWndTree, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, True)
    
            Dim NameSpaceTreeControl2 As Object = Activator.CreateInstance(NameSpaceTreeControlType)
            pNameSpaceTreeControl2 = DirectCast(NameSpaceTreeControl2, INameSpaceTreeControl)
            hr = pNameSpaceTreeControl2.Initialize(PictureBox2.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS Or NSTCSTYLE.NSTCS_HASLINES)
            If (hr = HRESULT.S_OK) Then
                Dim pidl As IntPtr = IntPtr.Zero
                hr = SHGetFolderLocation(IntPtr.Zero, CSIDL_DESKTOP, IntPtr.Zero, 0, pidl)
                If (hr = HRESULT.S_OK) Then
                    Dim psi As IntPtr = IntPtr.Zero
                    Dim GUID_IShellItem As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
                    hr = SHCreateItemFromIDList(pidl, GUID_IShellItem, psi)
                    If (hr = HRESULT.S_OK) Then
                        hr = pNameSpaceTreeControl2.AppendRoot(psi, SHCONTF.SHCONTF_FOLDERS Or SHCONTF.SHCONTF_NONFOLDERS, NSTCROOTSTYLE.NSTCRS_EXPANDED, IntPtr.Zero)
                        If (hr = HRESULT.S_OK) Then
                        End If
                    End If
                End If
            End If
            Dim hWndTree2 As IntPtr = FindWindowEx(PictureBox2.Handle, IntPtr.Zero, "NameSpaceTreeControl", Nothing)
            MoveWindow(hWndTree2, 0, 0, Me.PictureBox2.Width, Me.PictureBox2.Height, True)
    
            Me.ClientSize = New Size(660, 440)
            CenterToScreen()
        End Sub
    End Class
    
    

    • Marked as answer by ahmeddc Wednesday, September 26, 2018 9:04 AM
    Monday, September 24, 2018 8:15 AM
  •  I could be wrong but,  maybe you want to resize the TreeView?  If so,  you could change the size of the PictureBox controls...

    Me.PictureBox1.Size = New System.Drawing.Size(300, 140)
    ....
    Me.PictureBox2.Size = New System.Drawing.Size(300, 140)
     

     

     If you have changed the treeview's parent to the Form,  then you could change the size of it in the two calls to the MoveWindow function...

     
    MoveWindow(hWndTree, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, True)
    ....
    MoveWindow(hWndTree2, 0, 0, Me.PictureBox2.Width, Me.PictureBox2.Height, True)
     

     

     Also,  if you want to remove the lines on the left,  then remove the NSTCSTYLE.NSTCS_HASLINES style from the two Initialize function calls like this...

            Dim hr As HRESULT = pNameSpaceTreeControl.Initialize(PictureBox1.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS)
    ....
    hr = pNameSpaceTreeControl2.Initialize(PictureBox2.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS)


     

     That makes the treeview look like this...


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, September 25, 2018 10:47 PM
    • Marked as answer by ahmeddc Wednesday, September 26, 2018 9:04 AM
    Tuesday, September 25, 2018 10:43 PM

All replies

  • Hi,

    You can try the following code :

    Public Class Form1
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            Try
                Dim mNode As TreeNode = Me.TreeView1.Nodes.Add("Fruits")
                mNode.Nodes.Add("Apple")
                mNode.Nodes.Add("Peach")
                mNode.Expand()
                mNode = Me.TreeView2.Nodes.Add("Vegetables")
                mNode.Nodes.Add("Tomato")
                mNode.Nodes.Add("Eggplant")
                mNode.Expand()
                Me.TreeView1.AllowDrop = True
                Me.TreeView2.AllowDrop = True
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
        End Sub
    
        Private Sub TreeView1_MouseDown(sender As Object, e As MouseEventArgs) Handles TreeView1.MouseDown
            Try
                Dim mTree As TreeView = sender
                Dim mNode As TreeNode = mTree.GetNodeAt(e.X, e.Y)
                mTree.SelectedNode = mNode
                If Not mNode Is Nothing Then
                    mTree.DoDragDrop(mNode.Clone, DragDropEffects.Copy)
                End If
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
        End Sub
    
        Private Sub TreeView2_DragOver(sender As Object, e As DragEventArgs) Handles TreeView2.DragOver
            Try
                Dim Tree As TreeView = sender
                e.Effect = DragDropEffects.None
    
                If Not CType(e.Data.GetData(GetType(TreeNode)), TreeNode) Is Nothing Then
                    Dim pt As Point = New Point(e.X, e.Y)
                    pt = Tree.PointToClient(pt)
    
                    Dim mNode As TreeNode = Tree.GetNodeAt(pt)
                    If Not mNode Is Nothing Then
                        e.Effect = DragDropEffects.Copy
                        Tree.SelectedNode = mNode
                    End If
                End If
    
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
        End Sub
    
        Private Sub TreeView2_DragDrop(sender As Object, e As DragEventArgs) Handles TreeView2.DragDrop
            Try
                Dim Tree As TreeView = sender
                Dim pt As Point = New Point(e.X, e.Y)
                pt = Tree.PointToClient(pt)
                Dim mNode As TreeNode = Tree.GetNodeAt(pt)
                mNode.Nodes.Add(CType(e.Data.GetData(GetType(TreeNode)), TreeNode))
                mNode.Expand()
            Catch ex As Exception
                MsgBox(ex.Message)
            End Try
    
        End Sub
    End Class
    

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 24, 2018 7:11 AM
  • hi  Alex

    I want by copying the folder from  TreeView1  copy folder to TreeView2not display only


    Monday, September 24, 2018 7:27 AM
  • Hi,

    What you want is not this effect?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 24, 2018 7:37 AM
  • Hi,

    What you want is not this effect?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    This is done with me in TreeView1 for the folders
    But when you browse the Windows Explorer, the folder does not appear real


    • Edited by ahmeddc Monday, September 24, 2018 7:47 AM
    Monday, September 24, 2018 7:44 AM
  • You can use INameSpaceTreeControl which embeds Explorer TreeView and handles everything automatically

    A sample (I created them inside Picture Boxes, but you can also create them as child of the main form) =>

    Option Strict On
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Public Enum HRESULT As Integer
            S_OK = 0
            S_FALSE = 1
            E_NOINTERFACE = &H80004002
            E_NOTIMPL = &H80004001
            E_FAIL = &H80004005
        End Enum
    
        <StructLayout(LayoutKind.Sequential)>
        Public Structure RECT
            Public Left As Integer
            Public Top As Integer
            Public Right As Integer
            Public Bottom As Integer
        End Structure
    
        Public Enum NSTCSTYLE As Integer
            NSTCS_HASEXPANDOS = &H1
            NSTCS_HASLINES = &H2
            NSTCS_SINGLECLICKEXPAND = &H4
            NSTCS_FULLROWSELECT = &H8
            NSTCS_SPRINGEXPAND = &H10
            NSTCS_HORIZONTALSCROLL = &H20
            NSTCS_ROOTHASEXPANDO = &H40
            NSTCS_SHOWSELECTIONALWAYS = &H80
            NSTCS_NOINFOTIP = &H200
            NSTCS_EVENHEIGHT = &H400
            NSTCS_NOREPLACEOPEN = &H800
            NSTCS_DISABLEDRAGDROP = &H1000
            NSTCS_NOORDERSTREAM = &H2000
            NSTCS_RICHTOOLTIP = &H4000
            NSTCS_BORDER = &H8000
            NSTCS_NOEDITLABELS = &H10000
            NSTCS_TABSTOP = &H20000
            NSTCS_FAVORITESMODE = &H80000
            NSTCS_AUTOHSCROLL = &H100000
            NSTCS_FADEINOUTEXPANDOS = &H200000
            NSTCS_EMPTYTEXT = &H400000
            NSTCS_CHECKBOXES = &H800000
            NSTCS_PARTIALCHECKBOXES = &H1000000
            NSTCS_EXCLUSIONCHECKBOXES = &H2000000
            NSTCS_DIMMEDCHECKBOXES = &H4000000
            NSTCS_NOINDENTCHECKS = &H8000000
            NSTCS_ALLOWJUNCTIONS = &H10000000
            NSTCS_SHOWTABSBUTTON = &H20000000
            NSTCS_SHOWDELETEBUTTON = &H40000000
            NSTCS_SHOWREFRESHBUTTON = &H80000000
        End Enum
    
        Public Enum SHCONTF As Integer
            SHCONTF_CHECKING_FOR_CHILDREN = &H10
            SHCONTF_FOLDERS = &H20
            SHCONTF_NONFOLDERS = &H40
            SHCONTF_INCLUDEHIDDEN = &H80
            SHCONTF_INIT_ON_FIRST_NEXT = &H100
            SHCONTF_NETPRINTERSRCH = &H200
            SHCONTF_SHAREABLE = &H400
            SHCONTF_STORAGE = &H800
            SHCONTF_NAVIGATION_ENUM = &H1000
            SHCONTF_FASTITEMS = &H2000
            SHCONTF_FLATLIST = &H4000
            SHCONTF_ENABLE_ASYNC = &H8000
            SHCONTF_INCLUDESUPERHIDDEN = &H10000
        End Enum
        Public Enum NSTCROOTSTYLE As Integer
            NSTCRS_VISIBLE = 0
            NSTCRS_HIDDEN = &H1
            NSTCRS_EXPANDED = &H2
        End Enum
        Public Enum NSTCITEMSTATE As Integer
            NSTCIS_NONE = 0
            NSTCIS_SELECTED = &H1
            NSTCIS_EXPANDED = &H2
            NSTCIS_BOLD = &H4
            NSTCIS_DISABLED = &H8
            NSTCIS_SELECTEDNOEXPAND = &H10
        End Enum
    
        Public Enum NSTCGNI As Integer
            NSTCGNI_NEXT = 0
            NSTCGNI_NEXTVISIBLE = 1
            NSTCGNI_PREV = 2
            NSTCGNI_PREVVISIBLE = 3
            NSTCGNI_PARENT = 4
            NSTCGNI_CHILD = 5
            NSTCGNI_FIRSTVISIBLE = 6
            NSTCGNI_LASTVISIBLE = 7
        End Enum
    
    
        <ComImport>
        <Guid("028212A3-B627-47e9-8856-C14265554E4F")>
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        Public Interface INameSpaceTreeControl
            Function Initialize(hwndParent As IntPtr, ByRef prc As RECT, nsctsFlags As NSTCSTYLE) As HRESULT
            Function TreeAdvise(punk As IntPtr, ByVal pdwCookie As Integer) As HRESULT
            Function TreeUnadvise(pdwCookie As Integer) As HRESULT
            Function AppendRoot(psiRoot As IntPtr, grfEnumFlags As SHCONTF, grfRootStyle As NSTCROOTSTYLE, pif As IntPtr) As HRESULT
            Function InsertRoot(iIndex As Integer, psiRoot As IntPtr, grfEnumFlags As SHCONTF, grfRootStyle As NSTCROOTSTYLE, pif As IntPtr) As HRESULT
            Function RemoveRoot(psiRoot As IntPtr) As HRESULT
            Function RemoveAllRoots() As HRESULT
            Function GetRootItems(ByVal ppsiaRootItems As IntPtr) As HRESULT
            Function SetItemState(psi As IntPtr, nstcisMask As NSTCITEMSTATE, nstcisFlags As NSTCITEMSTATE) As HRESULT
            Function GetItemState(psi As IntPtr, nstcisMask As NSTCITEMSTATE, ByVal pnstcisFlags As NSTCITEMSTATE) As HRESULT
            Function GetSelectedItems(ByVal psiaItems As IntPtr) As HRESULT
            Function GetItemCustomState(psi As IntPtr, ByVal piStateNumber As Integer) As HRESULT
            Function SetItemCustomState(psi As IntPtr, iStateNumber As Integer) As HRESULT
            Function EnsureItemVisible(psi As IntPtr) As HRESULT
            Function SetTheme(pszTheme As String) As HRESULT
            Function GetNextItem(psi As IntPtr, nstcgi As NSTCGNI, ByVal ppsiNext As IntPtr) As HRESULT
            Function HitTest(ppt As Point, nstcgi As NSTCGNI, ByVal ppsiOut As IntPtr) As HRESULT
            Function GetItemRect(psi As IntPtr, ByRef prect As RECT) As HRESULT
            Function CollapseAll() As HRESULT
        End Interface
    
        Public CSIDL_DESKTOP As Integer = 0
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function SHGetFolderLocation(ByVal hwndOwner As IntPtr, ByVal nFolder As Integer, ByVal hToken As IntPtr, ByVal dwReserved As UInteger, <Out> ByRef ppidl As IntPtr) As HRESULT
        End Function
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function SHCreateItemFromIDList(ByVal pidl As IntPtr, <[In], MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, <Out> ByRef ppv As IntPtr) As HRESULT
        End Function
    
        <DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function MoveWindow(hWnd As IntPtr, X As Integer, Y As Integer, nWidth As Integer, nHeight As Integer, bRepaint As Boolean) As Boolean
        End Function
    
        <DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function FindWindowEx(ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
        End Function
    
        <DllImport("Ole32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function OleInitialize(pvReserved As IntPtr) As HRESULT
        End Function
    
        Dim pNameSpaceTreeControl, pNameSpaceTreeControl2 As INameSpaceTreeControl
    
        Friend WithEvents PictureBox1, PictureBox2 As PictureBox
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Me.PictureBox1 = New PictureBox()
            Me.PictureBox1.Location = New System.Drawing.Point(20, 20)
            Me.PictureBox1.Name = "PictureBox1"
            Me.PictureBox1.Size = New System.Drawing.Size(300, 400)
            Me.PictureBox1.TabIndex = 0
            Me.PictureBox1.TabStop = False
            Me.PictureBox1.BorderStyle = BorderStyle.FixedSingle
            Me.Controls.Add(Me.PictureBox1)
    
            Me.PictureBox2 = New PictureBox()
            Me.PictureBox2.Location = New System.Drawing.Point(340, 20)
            Me.PictureBox2.Name = "PictureBox2"
            Me.PictureBox2.Size = New System.Drawing.Size(300, 400)
            Me.PictureBox2.TabIndex = 1
            Me.PictureBox2.TabStop = False
            Me.PictureBox2.BorderStyle = BorderStyle.FixedSingle
            Me.Controls.Add(Me.PictureBox2)
    
            OleInitialize(IntPtr.Zero)
            Dim CLSID_NamespaceTreeControl As New Guid("AE054212-3535-4430-83ED-D501AA6680E6")
            Dim NameSpaceTreeControlType As Type = Type.GetTypeFromCLSID(CLSID_NamespaceTreeControl, True)
            Dim NameSpaceTreeControl As Object = Activator.CreateInstance(NameSpaceTreeControlType)
            pNameSpaceTreeControl = DirectCast(NameSpaceTreeControl, INameSpaceTreeControl)
            Dim hr As HRESULT = pNameSpaceTreeControl.Initialize(PictureBox1.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS Or NSTCSTYLE.NSTCS_HASLINES)
            If (hr = HRESULT.S_OK) Then
                Dim pidl As IntPtr = IntPtr.Zero
                hr = SHGetFolderLocation(IntPtr.Zero, CSIDL_DESKTOP, IntPtr.Zero, 0, pidl)
                If (hr = HRESULT.S_OK) Then
                    Dim psi As IntPtr = IntPtr.Zero
                    Dim GUID_IShellItem As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
                    hr = SHCreateItemFromIDList(pidl, GUID_IShellItem, psi)
                    If (hr = HRESULT.S_OK) Then
                        hr = pNameSpaceTreeControl.AppendRoot(psi, SHCONTF.SHCONTF_FOLDERS Or SHCONTF.SHCONTF_NONFOLDERS, NSTCROOTSTYLE.NSTCRS_EXPANDED, IntPtr.Zero)
                        If (hr = HRESULT.S_OK) Then
                        End If
                    End If
                End If
            End If
            Dim hWndTree As IntPtr = FindWindowEx(PictureBox1.Handle, IntPtr.Zero, "NameSpaceTreeControl", Nothing)
            MoveWindow(hWndTree, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, True)
    
            Dim NameSpaceTreeControl2 As Object = Activator.CreateInstance(NameSpaceTreeControlType)
            pNameSpaceTreeControl2 = DirectCast(NameSpaceTreeControl2, INameSpaceTreeControl)
            hr = pNameSpaceTreeControl2.Initialize(PictureBox2.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS Or NSTCSTYLE.NSTCS_HASLINES)
            If (hr = HRESULT.S_OK) Then
                Dim pidl As IntPtr = IntPtr.Zero
                hr = SHGetFolderLocation(IntPtr.Zero, CSIDL_DESKTOP, IntPtr.Zero, 0, pidl)
                If (hr = HRESULT.S_OK) Then
                    Dim psi As IntPtr = IntPtr.Zero
                    Dim GUID_IShellItem As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
                    hr = SHCreateItemFromIDList(pidl, GUID_IShellItem, psi)
                    If (hr = HRESULT.S_OK) Then
                        hr = pNameSpaceTreeControl2.AppendRoot(psi, SHCONTF.SHCONTF_FOLDERS Or SHCONTF.SHCONTF_NONFOLDERS, NSTCROOTSTYLE.NSTCRS_EXPANDED, IntPtr.Zero)
                        If (hr = HRESULT.S_OK) Then
                        End If
                    End If
                End If
            End If
            Dim hWndTree2 As IntPtr = FindWindowEx(PictureBox2.Handle, IntPtr.Zero, "NameSpaceTreeControl", Nothing)
            MoveWindow(hWndTree2, 0, 0, Me.PictureBox2.Width, Me.PictureBox2.Height, True)
    
            Me.ClientSize = New Size(660, 440)
            CenterToScreen()
        End Sub
    End Class
    
    

    • Marked as answer by ahmeddc Wednesday, September 26, 2018 9:04 AM
    Monday, September 24, 2018 8:15 AM
  • You can use INameSpaceTreeControl which embeds Explorer TreeView and handles everything automatically

    A sample (I created them inside Picture Boxes, but you can also create them as child of the main form) =>

    Option Strict On
    Imports System.Runtime.InteropServices
    
    Public Class Form1
        Public Enum HRESULT As Integer
            S_OK = 0
            S_FALSE = 1
            E_NOINTERFACE = &H80004002
            E_NOTIMPL = &H80004001
            E_FAIL = &H80004005
        End Enum
    
        <StructLayout(LayoutKind.Sequential)>
        Public Structure RECT
            Public Left As Integer
            Public Top As Integer
            Public Right As Integer
            Public Bottom As Integer
        End Structure
    
        Public Enum NSTCSTYLE As Integer
            NSTCS_HASEXPANDOS = &H1
            NSTCS_HASLINES = &H2
            NSTCS_SINGLECLICKEXPAND = &H4
            NSTCS_FULLROWSELECT = &H8
            NSTCS_SPRINGEXPAND = &H10
            NSTCS_HORIZONTALSCROLL = &H20
            NSTCS_ROOTHASEXPANDO = &H40
            NSTCS_SHOWSELECTIONALWAYS = &H80
            NSTCS_NOINFOTIP = &H200
            NSTCS_EVENHEIGHT = &H400
            NSTCS_NOREPLACEOPEN = &H800
            NSTCS_DISABLEDRAGDROP = &H1000
            NSTCS_NOORDERSTREAM = &H2000
            NSTCS_RICHTOOLTIP = &H4000
            NSTCS_BORDER = &H8000
            NSTCS_NOEDITLABELS = &H10000
            NSTCS_TABSTOP = &H20000
            NSTCS_FAVORITESMODE = &H80000
            NSTCS_AUTOHSCROLL = &H100000
            NSTCS_FADEINOUTEXPANDOS = &H200000
            NSTCS_EMPTYTEXT = &H400000
            NSTCS_CHECKBOXES = &H800000
            NSTCS_PARTIALCHECKBOXES = &H1000000
            NSTCS_EXCLUSIONCHECKBOXES = &H2000000
            NSTCS_DIMMEDCHECKBOXES = &H4000000
            NSTCS_NOINDENTCHECKS = &H8000000
            NSTCS_ALLOWJUNCTIONS = &H10000000
            NSTCS_SHOWTABSBUTTON = &H20000000
            NSTCS_SHOWDELETEBUTTON = &H40000000
            NSTCS_SHOWREFRESHBUTTON = &H80000000
        End Enum
    
        Public Enum SHCONTF As Integer
            SHCONTF_CHECKING_FOR_CHILDREN = &H10
            SHCONTF_FOLDERS = &H20
            SHCONTF_NONFOLDERS = &H40
            SHCONTF_INCLUDEHIDDEN = &H80
            SHCONTF_INIT_ON_FIRST_NEXT = &H100
            SHCONTF_NETPRINTERSRCH = &H200
            SHCONTF_SHAREABLE = &H400
            SHCONTF_STORAGE = &H800
            SHCONTF_NAVIGATION_ENUM = &H1000
            SHCONTF_FASTITEMS = &H2000
            SHCONTF_FLATLIST = &H4000
            SHCONTF_ENABLE_ASYNC = &H8000
            SHCONTF_INCLUDESUPERHIDDEN = &H10000
        End Enum
        Public Enum NSTCROOTSTYLE As Integer
            NSTCRS_VISIBLE = 0
            NSTCRS_HIDDEN = &H1
            NSTCRS_EXPANDED = &H2
        End Enum
        Public Enum NSTCITEMSTATE As Integer
            NSTCIS_NONE = 0
            NSTCIS_SELECTED = &H1
            NSTCIS_EXPANDED = &H2
            NSTCIS_BOLD = &H4
            NSTCIS_DISABLED = &H8
            NSTCIS_SELECTEDNOEXPAND = &H10
        End Enum
    
        Public Enum NSTCGNI As Integer
            NSTCGNI_NEXT = 0
            NSTCGNI_NEXTVISIBLE = 1
            NSTCGNI_PREV = 2
            NSTCGNI_PREVVISIBLE = 3
            NSTCGNI_PARENT = 4
            NSTCGNI_CHILD = 5
            NSTCGNI_FIRSTVISIBLE = 6
            NSTCGNI_LASTVISIBLE = 7
        End Enum
    
    
        <ComImport>
        <Guid("028212A3-B627-47e9-8856-C14265554E4F")>
        <InterfaceType(ComInterfaceType.InterfaceIsIUnknown)>
        Public Interface INameSpaceTreeControl
            Function Initialize(hwndParent As IntPtr, ByRef prc As RECT, nsctsFlags As NSTCSTYLE) As HRESULT
            Function TreeAdvise(punk As IntPtr, ByVal pdwCookie As Integer) As HRESULT
            Function TreeUnadvise(pdwCookie As Integer) As HRESULT
            Function AppendRoot(psiRoot As IntPtr, grfEnumFlags As SHCONTF, grfRootStyle As NSTCROOTSTYLE, pif As IntPtr) As HRESULT
            Function InsertRoot(iIndex As Integer, psiRoot As IntPtr, grfEnumFlags As SHCONTF, grfRootStyle As NSTCROOTSTYLE, pif As IntPtr) As HRESULT
            Function RemoveRoot(psiRoot As IntPtr) As HRESULT
            Function RemoveAllRoots() As HRESULT
            Function GetRootItems(ByVal ppsiaRootItems As IntPtr) As HRESULT
            Function SetItemState(psi As IntPtr, nstcisMask As NSTCITEMSTATE, nstcisFlags As NSTCITEMSTATE) As HRESULT
            Function GetItemState(psi As IntPtr, nstcisMask As NSTCITEMSTATE, ByVal pnstcisFlags As NSTCITEMSTATE) As HRESULT
            Function GetSelectedItems(ByVal psiaItems As IntPtr) As HRESULT
            Function GetItemCustomState(psi As IntPtr, ByVal piStateNumber As Integer) As HRESULT
            Function SetItemCustomState(psi As IntPtr, iStateNumber As Integer) As HRESULT
            Function EnsureItemVisible(psi As IntPtr) As HRESULT
            Function SetTheme(pszTheme As String) As HRESULT
            Function GetNextItem(psi As IntPtr, nstcgi As NSTCGNI, ByVal ppsiNext As IntPtr) As HRESULT
            Function HitTest(ppt As Point, nstcgi As NSTCGNI, ByVal ppsiOut As IntPtr) As HRESULT
            Function GetItemRect(psi As IntPtr, ByRef prect As RECT) As HRESULT
            Function CollapseAll() As HRESULT
        End Interface
    
        Public CSIDL_DESKTOP As Integer = 0
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function SHGetFolderLocation(ByVal hwndOwner As IntPtr, ByVal nFolder As Integer, ByVal hToken As IntPtr, ByVal dwReserved As UInteger, <Out> ByRef ppidl As IntPtr) As HRESULT
        End Function
    
        <DllImport("Shell32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function SHCreateItemFromIDList(ByVal pidl As IntPtr, <[In], MarshalAs(UnmanagedType.LPStruct)> ByVal riid As Guid, <Out> ByRef ppv As IntPtr) As HRESULT
        End Function
    
        <DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function MoveWindow(hWnd As IntPtr, X As Integer, Y As Integer, nWidth As Integer, nHeight As Integer, bRepaint As Boolean) As Boolean
        End Function
    
        <DllImport("User32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function FindWindowEx(ByVal hWndParent As IntPtr, ByVal hWndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
        End Function
    
        <DllImport("Ole32.dll", CharSet:=CharSet.Auto, SetLastError:=True)>
        Public Shared Function OleInitialize(pvReserved As IntPtr) As HRESULT
        End Function
    
        Dim pNameSpaceTreeControl, pNameSpaceTreeControl2 As INameSpaceTreeControl
    
        Friend WithEvents PictureBox1, PictureBox2 As PictureBox
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
            Me.PictureBox1 = New PictureBox()
            Me.PictureBox1.Location = New System.Drawing.Point(20, 20)
            Me.PictureBox1.Name = "PictureBox1"
            Me.PictureBox1.Size = New System.Drawing.Size(300, 400)
            Me.PictureBox1.TabIndex = 0
            Me.PictureBox1.TabStop = False
            Me.PictureBox1.BorderStyle = BorderStyle.FixedSingle
            Me.Controls.Add(Me.PictureBox1)
    
            Me.PictureBox2 = New PictureBox()
            Me.PictureBox2.Location = New System.Drawing.Point(340, 20)
            Me.PictureBox2.Name = "PictureBox2"
            Me.PictureBox2.Size = New System.Drawing.Size(300, 400)
            Me.PictureBox2.TabIndex = 1
            Me.PictureBox2.TabStop = False
            Me.PictureBox2.BorderStyle = BorderStyle.FixedSingle
            Me.Controls.Add(Me.PictureBox2)
    
            OleInitialize(IntPtr.Zero)
            Dim CLSID_NamespaceTreeControl As New Guid("AE054212-3535-4430-83ED-D501AA6680E6")
            Dim NameSpaceTreeControlType As Type = Type.GetTypeFromCLSID(CLSID_NamespaceTreeControl, True)
            Dim NameSpaceTreeControl As Object = Activator.CreateInstance(NameSpaceTreeControlType)
            pNameSpaceTreeControl = DirectCast(NameSpaceTreeControl, INameSpaceTreeControl)
            Dim hr As HRESULT = pNameSpaceTreeControl.Initialize(PictureBox1.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS Or NSTCSTYLE.NSTCS_HASLINES)
            If (hr = HRESULT.S_OK) Then
                Dim pidl As IntPtr = IntPtr.Zero
                hr = SHGetFolderLocation(IntPtr.Zero, CSIDL_DESKTOP, IntPtr.Zero, 0, pidl)
                If (hr = HRESULT.S_OK) Then
                    Dim psi As IntPtr = IntPtr.Zero
                    Dim GUID_IShellItem As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
                    hr = SHCreateItemFromIDList(pidl, GUID_IShellItem, psi)
                    If (hr = HRESULT.S_OK) Then
                        hr = pNameSpaceTreeControl.AppendRoot(psi, SHCONTF.SHCONTF_FOLDERS Or SHCONTF.SHCONTF_NONFOLDERS, NSTCROOTSTYLE.NSTCRS_EXPANDED, IntPtr.Zero)
                        If (hr = HRESULT.S_OK) Then
                        End If
                    End If
                End If
            End If
            Dim hWndTree As IntPtr = FindWindowEx(PictureBox1.Handle, IntPtr.Zero, "NameSpaceTreeControl", Nothing)
            MoveWindow(hWndTree, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, True)
    
            Dim NameSpaceTreeControl2 As Object = Activator.CreateInstance(NameSpaceTreeControlType)
            pNameSpaceTreeControl2 = DirectCast(NameSpaceTreeControl2, INameSpaceTreeControl)
            hr = pNameSpaceTreeControl2.Initialize(PictureBox2.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS Or NSTCSTYLE.NSTCS_HASLINES)
            If (hr = HRESULT.S_OK) Then
                Dim pidl As IntPtr = IntPtr.Zero
                hr = SHGetFolderLocation(IntPtr.Zero, CSIDL_DESKTOP, IntPtr.Zero, 0, pidl)
                If (hr = HRESULT.S_OK) Then
                    Dim psi As IntPtr = IntPtr.Zero
                    Dim GUID_IShellItem As New Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")
                    hr = SHCreateItemFromIDList(pidl, GUID_IShellItem, psi)
                    If (hr = HRESULT.S_OK) Then
                        hr = pNameSpaceTreeControl2.AppendRoot(psi, SHCONTF.SHCONTF_FOLDERS Or SHCONTF.SHCONTF_NONFOLDERS, NSTCROOTSTYLE.NSTCRS_EXPANDED, IntPtr.Zero)
                        If (hr = HRESULT.S_OK) Then
                        End If
                    End If
                End If
            End If
            Dim hWndTree2 As IntPtr = FindWindowEx(PictureBox2.Handle, IntPtr.Zero, "NameSpaceTreeControl", Nothing)
            MoveWindow(hWndTree2, 0, 0, Me.PictureBox2.Width, Me.PictureBox2.Height, True)
    
            Me.ClientSize = New Size(660, 440)
            CenterToScreen()
        End Sub
    End Class
    

    much thanks

    Is there a way to show the specified part in red?        part a in image


    And the elimination of the property of evidence by hand to know how to control their properties
      part b in image


    Monday, September 24, 2018 12:40 PM
  • Sorry, I don't understand what you mean by "the specified part in red"

    (you selected 4 folders, but I don't see their particularity and why they should be in red... )

    Tuesday, September 25, 2018 1:24 PM
  •  I could be wrong but,  maybe you want to resize the TreeView?  If so,  you could change the size of the PictureBox controls...

    Me.PictureBox1.Size = New System.Drawing.Size(300, 140)
    ....
    Me.PictureBox2.Size = New System.Drawing.Size(300, 140)
     

     

     If you have changed the treeview's parent to the Form,  then you could change the size of it in the two calls to the MoveWindow function...

     
    MoveWindow(hWndTree, 0, 0, Me.PictureBox1.Width, Me.PictureBox1.Height, True)
    ....
    MoveWindow(hWndTree2, 0, 0, Me.PictureBox2.Width, Me.PictureBox2.Height, True)
     

     

     Also,  if you want to remove the lines on the left,  then remove the NSTCSTYLE.NSTCS_HASLINES style from the two Initialize function calls like this...

            Dim hr As HRESULT = pNameSpaceTreeControl.Initialize(PictureBox1.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS)
    ....
    hr = pNameSpaceTreeControl2.Initialize(PictureBox2.Handle, Nothing, NSTCSTYLE.NSTCS_RICHTOOLTIP Or NSTCSTYLE.NSTCS_FAVORITESMODE Or NSTCSTYLE.NSTCS_FULLROWSELECT Or NSTCSTYLE.NSTCS_NOREPLACEOPEN Or NSTCSTYLE.NSTCS_AUTOHSCROLL Or NSTCSTYLE.NSTCS_HASEXPANDOS)


     

     That makes the treeview look like this...


    If you say it can`t be done then i`ll try it

    • Edited by IronRazerz Tuesday, September 25, 2018 10:47 PM
    • Marked as answer by ahmeddc Wednesday, September 26, 2018 9:04 AM
    Tuesday, September 25, 2018 10:43 PM