如何使用复选框配置 ASP .Net 树视图的垂直间距
显示很糟糕;行与行之间有一些空格。
我在网页中使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 blogs.msdn.com
I've found a workaround on blogs.msdn.com