如何使用复选框配置 ASP .Net 树视图的垂直间距

发布于 2024-10-05 09:18:49 字数 2347 浏览 5 评论 0原文

显示很糟糕;行与行之间有一些空格。

我在网页中使用 asp:treeview 。外观是用皮肤配置的。TreeViewSkin 被写入 App_Themes 下可用的 SkinFile.skin 中:

<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>

有关信息,数据绑定由 完成>BuildTreeview 方法:

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);
    }
}

我不是代码的所有者;我承认该方法的代码有些晦涩...... 显示复选框是否错误?我可以使用 Chrome 使用此 示例 进行部分复制但在 IE7 中不行。我很失望;)

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 ;)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

终弃我 2024-10-12 09:18:49

我在 blogs.msdn.com

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

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

The {DIV} tag generated height is only 1px instead of 20px. 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文