2010-11-30 27 views
0

display非常糟糕;線條之間有一些空格。我在網頁中使用asp:treeview。外觀配置了skin.The TreeViewSkin寫入SkinFile.skin可用App_Themes下:如何使用複選框配置ASP .Net樹視圖的垂直間距

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

我不是代碼的所有者;我承認這個方法的代碼有些模糊...... 顯示覆選框是錯誤的嗎?我可以通過這個sample與Chrome部分重現,但不能在IE7中重現。我很失望;)

回答