Avatar of Tom Powers
Tom Powers

asked on 

VB.net how to have combbox selection sort to the idenical treeview Node?

I'm developing in VB.NET 2017 .NET 4.5.2
I just need the  combbox selection to sort to the idenical treeview Node? In my Combo box contains all the workstations in AD OU the Treeview has identical names as nodes I want when I combo box is selected the Computername becomes Highlighted in the Treeview Node. I can do it as combo box to sort to a listview however the Treeview is not a control that I can use it to it's Fullest.
Here is a Visual I got Tree to combo box but not combo box to Tree view.
Visual of what I described
hERE IS CODE THAT ALLOWED ME TO SORT FROM COMBO BOX TO lISTVIEW CONTROL. vb.net pLEASE
 Public Function FindItem(ByVal LV As ListView, ByVal TextToFind As String) As Integer



        ' Loop through LV’s ListViewItems.

        For i As Integer = 0 To LV.Items.Count - 1

            If Trim(LV.Items(i).Text) = Trim(TextToFind) Then

                ' If found, return the row number

                Return (i)

            End If

            For subitem As Integer = 0 To LV.Items(i).SubItems.Count - 1

                If Trim(LV.Items(i).SubItems(subitem).Text) = Trim(TextToFind) Then

                    ' If found, return the row number

                    Return (i)

                End If

            Next

        Next

        ' If not found, then return -1.     Return -1

    End Function
    Public Sub FindPrinter()
        LSPrinters.MultiSelect = False

        LSPrinters.FullRowSelect = True





        Dim checkInt As Integer = FindItem(LSPrinters, cmbPrint.Text)

        If checkInt <> -1 Then

            LSPrinters.Items(checkInt).Selected = True

            LSPrinters.Focus()
            LSPrinters.SelectedItems(0).EnsureVisible()


        Else
            ToolStripLabel1.Text = "Search string not found"

        End If


    End Sub

Open in new window

WinApp.png
Visual Basic.NET* user controls.NET Programming

Avatar of undefined
Last Comment
Éric Moreau

8/22/2022 - Mon