שתף באמצעות


TreeView Item Select not Highlighting

Question

Monday, July 20, 2009 2:01 AM

Hi All,
I have a search function that opens a showdialog form that has a listview of items returned from the user search. The idea is the user selects from the listview and the matching item then selects in the tree view.

Okay so all works fine except that the selected item in the treeview does not highlight in blue like it should. It does indeed select it but it does not highlight.

Here is the listview SelectedIndexChanged event code.

Private Sub lstSearchResults_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lstSearchResults.SelectedIndexChanged
        If lstSearchResults.SelectedItems.Count > 0 Then
            Dim tn() As TreeNode = frmMain.TreeView1.Nodes.Find(lstSearchResults.SelectedItems(0).SubItems(0).Text, True)
            If tn.Length = 1 Then
                frmMain.TreeView1.SelectedNode = tn(0)
                frmMain.TreeView1.Focus()
            End If
        End If
    End Sub

So how do I get the treeview selected item highlighted? Keep in mind that I have a second dialog form (the search form) open at the same time.

Thanks

All replies (2)

Monday, July 20, 2009 4:18 AM | 2 votes

Normally such controls do not highlight selected item when they dont have focus, but there is a property called HideSelection in Treeview, that will help you to highlight node when treeview is not active control, but not active blue, i think its gray in standard mode.

TreeView1.HideSelection=False
If you want to select treeview use select instead of focus
TreeView1.Select()

Arjun Paudel


Monday, July 20, 2009 1:33 PM

Arjun,
Yes hideselection=false worked but as you stated it is gray. How do I turn it Blue like a standard selection?

Thanks!

Skip