Nach wrote:
> For Each tn As TreeNode In TreeView1.SelectedNode.Nodes
> *** If tn.ForeColor = Color.Blue Then ***
> Does not like above line. Can you give the correct syntax ???
You can't set individual properties on any Font object; you have to
create whole new ones:
Dim f As New Font( tn.Font )
f.Color = Color.Blue
tn.Font = f
> Also in Treeview we have the after select as shown below
>
> Private Sub TreeView1_AfterSelect( _
> ByVal sender As System.Object,
> , ByVal e As System.Windows.Forms.TreeViewEventArgs _
> ) Handles TreeView1.AfterSelect
>
> If TreeView1.Nodes.IndexOf(TreeView1.SelectedNode) = -1 Then
> TreeView1.SelectedNode.ForeColor = Color.Blue
> End If
>
> End Sub
What do you expect the above to do?
Change the selected Node to be Blue? Use the e.Node property:
e.Node.Font = ...
To reset all the others to "not Blue", you either have to loop through
the Nodes Collection [of the selected Node] and reset the colour, or use
the BeforeSelect event to "reset" the old one, before AfterSelect "sets"
the new one (I think! - haven't tried it).
Also, be aware that TreeView1.Nodes *only* contains the Nodes at the
/root/ of the Tree - each Node has its own collection of child Nodes, as
you work your way down the tree.
HTH,
Phill W.
|