PC Review


Reply
Thread Tools Rate Thread

Correct syntax in treeview attributes

 
 
=?Utf-8?B?TmFjaA==?=
Guest
Posts: n/a
 
      22nd Feb 2007
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 ???
I = I + 1
End If
Next tn

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

Do we have the same option in listview to turn certain lines a different color
and then going thru the collection to examine the lines that were changed ???



 
Reply With Quote
 
 
 
 
Phill W.
Guest
Posts: n/a
 
      23rd Feb 2007
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.
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Here is the syntax for TreeView.KeyDown(). baobob@my-deja.com Microsoft Excel Programming 0 13th May 2009 03:52 AM
treeview expand client-side attributes csabadapp@gmail.com Microsoft C# .NET 2 20th Apr 2007 01:18 PM
how to make sure a xsl document has valid xsl syntax? i tried loading it into an xml document but that doesnt show syntax errors inside attributes such as "foo/bar" vs "bar\foo" Daniel Microsoft C# .NET 0 31st Aug 2005 01:01 AM
Syntax for modifying attributes of relation =?Utf-8?B?QnJpYW4=?= Microsoft Access VBA Modules 0 23rd Sep 2004 09:49 PM
syntax of changing file attributes M K W Microsoft Excel Programming 0 26th Aug 2003 02:47 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:29 PM.