日期:2014-05-18  浏览次数:20404 次

vs2005中的Treeview怎样设置选中后的高亮颜色
vs2005中的Treeview怎样设置选中后的高亮颜色

------解决方案--------------------
设置SelectedNodeStyle的ForeColor
就可以用你自己设定的颜色高亮显示了

------解决方案--------------------
没办法只有添加个SPAN;





VB.NET code

//加载节点
  Dim tmpTreeNode As TreeNode
        For i = 0 To dteCatalogInfo.Rows.Count - 1
            tmpTreeNode = New TreeNode(dteCatalogInfo.Rows(i).Item(MATERIALINFO_DEFINE.MATERIAL_INFO_Name_FIELD).ToString)

            tmpTreeNode.Value = "00" & dteCatalogInfo.Rows(i).Item(MATERIALINFO_DEFINE.MATERIAL_INFO_ID_FIELD).ToString & "|" & dteCatalogInfo.Rows(i).Item(MATERIALINFO_DEFINE.MATERIAL_INFO_ID_FIELD).ToString
            tmpTreeNode.ImageUrl = "Img/book.gif"
            tmpTreeNode.NavigateUrl = "#&menuNodeID=" & dteCatalogInfo.Rows(i).Item(MATERIALINFO_DEFINE.MATERIAL_INFO_ID_FIELD).ToString
            tmpTreeNode.Expanded = True
            TreeView1.Nodes.Add(tmpTreeNode)
            SetNodeText(TreeView1.Nodes(TreeView1.Nodes.IndexOf(tmpTreeNode)))
        Next i


   Protected Sub SetNodeText(ByRef node As TreeNode)
        Dim id As String
        id = "spnode_" + node.Value
        node.Text = "<span style='cursor:hand' id='" + id + "' onclick=""SetNode('" + id + "','" + node.NavigateUrl + "','" + node.ValuePath + "')"" oncontextmenu=""SetNode('" + id + "','" + node.NavigateUrl + "','" + node.ValuePath + "') "">" + node.Text + "</span>"

    End Sub

------解决方案--------------------
楼上解..............