开发者

How to configure vertical spacing for ASP .Net treeview with checkbox

开发者 https://www.devze.com 2023-01-27 11:14 出处:网络
The display is awful; there are some spaces between lines. I\'m using a asp:treeview in my web page. The appearance is configured with skin.The TreeViewSkin is written into SkinFile.skin available un

The display is awful; there are some spaces between lines.

I'm using a asp:treeview in my web page. The appearance is configured with skin.The TreeViewSkin is written into SkinFile.skin available under App_Themes:

<asp:TreeView SkinID="TreeViewSkin" runat="server" ShowLines="true" ShowCheckBoxes="All" Style="margin-top:10px;">
  <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
  <NodeStyle Font-Names="Verdana" Font-Size="8pt" HorizontalPadding="5px" NodeSpacing="开发者_运维技巧0px" VerticalPadding="0px" />
  <ParentNodeStyle Font-Bold="False" />
  <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>

For information the data binding is done by BuildTreeview method:

public static void BuildTreeView<T>(this IEnumerable<HierarchyNode<T>> hierarchy, TreeView treeView, string idName, string libName) where T : class
{
    TreeNode treeNode = null;
    var treeview = typeof(T);
    foreach (var obj in hierarchy)
    {
        var nameProperty = obj.GetType().GetProperty("Entity");
        if (nameProperty == null) continue;
        var value = (T)nameProperty.GetValue(obj, null);
        var property = treeview.GetProperty(idName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
        var curElementIdValue = Convert.ToInt32(property.GetValue(value, null));

        var labelProperty = treeview.GetProperty(libName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
        var labelValue = (string)labelProperty.GetValue(value, null);

        if (value != null)  treeNode = new TreeNode() {Text = labelValue, Value = curElementIdValue.ToString()};

        var childNodes = obj.GetType().GetProperty("ChildNodes");
        if (childNodes != null) {
            var propValue = childNodes.GetValue(obj, null);
            BuildTreeNode<T>(propValue as IEnumerable, treeNode, idName, libName);
        }
        if (treeNode != null) treeView.Nodes.Add(treeNode);
    }
}

I'm not the code's owner; I admit that the code of the method is somewhat obscure... Is it wrong to show checkbox? I can reproduce partially with Chrome with this sample but not in IE7. I'm disappointed ;)


I've found a workaround on blogs.msdn.com

The {DIV} tag generated height is only 1px instead of 20px. 
0

精彩评论

暂无评论...
验证码 换一张
取 消