日期:2014-05-17 浏览次数:21738 次
reeView1.DrawMode = TreeViewDrawMode.OwnerDrawText
AddHandler TreeView1.DrawNode, AddressOf treeView_DrawNode
Private Sub treeView_DrawNode(ByVal sender As Object, ByVal e As DrawTreeNodeEventArgs)
Dim f As Font = If(e.Node.NodeFont IsNot Nothing, e.Node.NodeFont, e.Node.TreeView.Font)
Dim fore As Color = e.Node.ForeColor
'If fore = Color.Empty Then
' fore = e.Node.TreeView.ForeColor
'End If
If IsTreeNodeChanged(e.Node) Then
fore = Color.Red
End If
' Have to indicate focus somehow, how about yellow foreground text?
If e.Node Is e.Node.TreeView.SelectedNode Then
'fore = SystemColors.HighlightText
If (e.State And TreeNodeStates.Focused) <> 0 Then
f = New Font("Meiryo UI", 9.0!, FontStyle.Bold)
End If
End If
Dim sz As Size = TextRenderer.MeasureText(e.Node.Text, New Font("Meiryo UI", 9.0!, FontStyle.Bold))
Dim rc As New Rectangle(e.Bounds.X - 1, e.Bounds.Y, sz.Width + 2, e.Bounds.Height)
Dim back As Color = e.Node.BackColor
'If IsTreeNodeDiff(e.Node) Then
' back = Color.LightBlue
'Else
If back = Color.Empty Then
back = e.Node.TreeView.BackColor
End If
&n