gpt4 book ai didi

asp.net - TreeView — 所选节点样式不会出现在所选节点中

转载 作者:可可西里 更新时间:2023-11-01 13:17:51 30 4
gpt4 key购买 nike

我的代码是:

            <asp:TreeView ID="TreeViewCategories" runat="server" ExpandDepth="0" Style="min-height: 200px;
max-height: 500px;" LineImagesFolder="~/TreeLineImages" NodeIndent="0" LeafNodeStyle-CssClass="LeafNodesStyle"
CssClass="TreeView" NodeStyle-CssClass="NodeStyle" ParentNodeStyle-CssClass="ParentNodeStyle"
RootNodeStyle-CssClass="RootNodeStyle" SelectedNodeStyle-CssClass="SelectedNodeStyle"
LeafNodeStyle-Width="100%" NodeStyle-Width="100%" ParentNodeStyle-Width="100%"
RootNodeStyle-Width="100%" Font-Size="12pt">
<Nodes>
<asp:TreeNode Text="All Items" SelectAction="Expand" PopulateOnDemand="True" Value="All Items" />
</Nodes>
</asp:TreeView>

CSS

.TreeView  
{
border-bottom:1px dotted #B2B2B2 !important;
}

.TreeView div
{
margin-left:5px;
}

.TreeView table
{
border-top:1px dotted #B2B2B2 !important;
}

.TreeView div table
{
border-bottom:none !important;
border-top:none !important;
}

.TreeView table td
{
padding:2px 0;
}

.LeafNodesStyle
{

}

.RootNodeStyle
{

}

/* ALL ELEMENTS */

.NodeStyle
{

}

.ParentNodeStyle
{
/*background:yellow;*/
}

.SelectedNodeStyle { font-weight: bold; color:#6799D1; display:block; padding:2px 0 2px 3px; }

所以我看到(使用 Firebug )我选择的节点出现 Visited style , node style , leaf style 但不是 Selected node style :(

如何修复此 HTML/CSS/ASP 以使所选节点变为粗体和蓝色?

谢谢。

添加:像这里添加节点:

            foreach(c : Category in rootCategories)
{
mutable newNode : TreeNode = TreeNode(c.Title, c.Id);
newNode.SelectAction = TreeNodeSelectAction.SelectExpand;
newNode.NavigateUrl = "Items.aspx?catId=" + c.Id.ToString() + "&lvl=0";

用...解决

categoryId : string = Request.QueryString["catId"];
n : TreeNode = findNode(categoryId, TreeViewCategories.Nodes, lvl);
n.Selected = true;

最佳答案

asp:TreeNode 上的 SelectAction 属性是 Expand,将其更改为 SelectExpand .

这确保有一个回发并且重新绘制树控件以应用您在 TreeView 上设置的选定节点样式

<asp:TreeView ID="TreeViewCategories" runat="server" ExpandDepth="0" Style="min-height: 200px;
max-height: 500px;" LineImagesFolder="~/TreeLineImages" NodeIndent="0" LeafNodeStyle-CssClass="LeafNodesStyle"
CssClass="TreeView" NodeStyle-CssClass="NodeStyle" ParentNodeStyle-CssClass="ParentNodeStyle"
RootNodeStyle-CssClass="RootNodeStyle" SelectedNodeStyle-CssClass="SelectedNodeStyle"
LeafNodeStyle-Width="100%" NodeStyle-Width="100%" ParentNodeStyle-Width="100%"
RootNodeStyle-Width="100%" Font-Size="12pt">
<Nodes>
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items">
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
<asp:TreeNode Text="All Items" SelectAction="SelectExpand" Value="All Items" />
</asp:TreeNode>
</Nodes>
</asp:TreeView>

关于asp.net - TreeView — 所选节点样式不会出现在所选节点中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3455570/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com