(100分)webform中如何修改treeview 选中节点后的颜色
本帖最后由 a13951845000 于 2013-10-28 10:05:18 编辑
开发环境:vs2010,webform中如何修改treeview选中节点后的颜色。谢谢!
------解决方案--------------------public Form1()
{
InitializeComponent();
treeView1.HideSelection = true;
}
TreeNode preNode = null;
private void treeView1_BeforeSelect(object sender, TreeViewCancelEventArgs e)
{
if (preNode != null)
preNode.ForeColor = Color.Black;
e.Node.ForeColor = Color.Blue;
preNode = e.Node;
}
------解决方案--------------------楼上的不能实现,论坛有类似提问
------解决方案--------------------
展开treeview的属性SelectedNodeStyle,找到ForeColor,选择你想要的颜色
------解决方案--------------------<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TreeView.aspx.cs" Inherits="Galsun.Test.Web.TreeView" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<script>
var preNode;
function selval(obj, url, target) {
//alert(obj.innerHTML);
/*
var cb = obj.parentNode.parentNode.getElementsByTagName("input");
if (cb.length > 0)
cb[0].checked = true;
document.getElementById("<%= txt_path.ClientID %>").value = obj.innerHTML;
*/
if (preNode) preNode.style.color = "";
obj.style.backgroundColor = "#eeeeee";
preNode = obj;
//document.getElementById("<%=&n