换种方式吧,改成控制背景颜色
static pnd As object
Dim tree As windows.Forms.treeview = e.sender.basecontrol
Dim x As Integer = System.Windows.Forms.Cursor.Current.Position.X
Dim y As Integer = System.Windows.Forms.Cursor.Current.Position.Y
Dim pt = tree.PointToClient(new Point(X, Y)) '取当前坐标
Dim nd As System.Windows.Forms.TreeNode = tree.GetNodeAt(pt) '取坐标所在位置的节点
If nd Is Nothing OrElse pnd Is Nothing OrElse pnd.name <> nd.name Then
For Each nnd As WinForm.TreeNode In e.Sender.AllNodes
nnd.BackColor = color.white
nnd.ForeColor = color.black
Next
If nd IsNot Nothing
nd.BackColor = color.red
nd.ForeColor = color.yellow
End If
End If
pnd = nd