We help IT Professionals succeed at work.
Get Started

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

202 Views
Last Modified: 2017-11-16
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
Comment
Watch Question
Senior .Net Consultant
CERTIFIED EXPERT
Top Expert 2016
Commented:
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE