问题1:20分
vs2008 asp.net 的 treeview 线条是断的
特别是竖向的长些的,一断一断的很难看
怎么解决,做不到像mztreeview的连续的么?
我知道有不带线的样式,但是我还是喜欢有线的样式, 但是线不连贯怎么解决?不想用mztreeview等js做的,用起来很麻烦啊,主要是对js很生,看了许多网页也没学会,还是内置的好啊

解决方案 »

  1.   

    样式的问题加
    <style>
    *{padding:0;margin:0;font-size:12px}
    </style>
      

  2.   


    谢大侠回复
    我是如下这样加的,请看红色部分,不好使,一定是加错了地方,应该加在什么地方?<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Tree.aspx.cs" Inherits="a_a" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>无标题页</title>
    <style  type="text/css">
    *{padding:0;margin:0;font-size:12px}
    </style>

    </head><body>
            <form id="form1" runat="server">
            <asp:TreeView ID="TreeView1" runat="server" LineImagesFolder="TreeLineImages" 
                ShowLines="True" ImageSet="Simple" 
                onselectednodechanged="TreeView1_SelectedNodeChanged">
                <ParentNodeStyle Font-Bold="False" />
                <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
                <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" 
                    HorizontalPadding="0px" VerticalPadding="0px" />
                <Nodes>
                    <asp:TreeNode Text="学校各部门" Value="学校各部门">
                        <asp:TreeNode Text="教务处" Value="教务处"></asp:TreeNode>
                        <asp:TreeNode Text="德育处" Value="德育处"></asp:TreeNode>
                        <asp:TreeNode Text="后勤" Value="后勤"></asp:TreeNode>
                        <asp:TreeNode Text="工会" Value="工会"></asp:TreeNode>
                    </asp:TreeNode>
                    <asp:TreeNode Text="学年" Value="学年">
                        <asp:TreeNode Text="高一" Value="高一"></asp:TreeNode>
                        <asp:TreeNode Text="高二" Value="高二"></asp:TreeNode>
                        <asp:TreeNode Text="高三" Value="高三"></asp:TreeNode>
                    </asp:TreeNode>
                </Nodes>
                <NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" 
                    HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />
            </asp:TreeView>
            </form>
    </body></html>
      

  3.   

    你把里面的 Font-Size="10pt"去掉啊,里面已经定义了
      

  4.   

    我去掉了啊,空隙还是很大,特别是“学校各部门”到“学年”间的长线,空隙更大
    我已改如下,里面没有10pt了:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Tree.aspx.cs" Inherits="a_a" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
    <style  type="text/css">
    *{padding:0;margin:0;font-size:12px}
    </style>
    </head><body>
            <form id="form1" runat="server">
            <asp:TreeView ID="TreeView1" runat="server" LineImagesFolder="TreeLineImages" 
                ShowLines="True" ImageSet="Simple" 
                onselectednodechanged="TreeView1_SelectedNodeChanged">
                <ParentNodeStyle Font-Bold="False" />
                <HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
                <SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" 
                    HorizontalPadding="0px" VerticalPadding="0px" />
                <Nodes>
                    <asp:TreeNode Text="学校各部门" Value="学校各部门">
                        <asp:TreeNode Text="教务处" Value="教务处"></asp:TreeNode>
                        <asp:TreeNode Text="德育处" Value="德育处"></asp:TreeNode>
                        <asp:TreeNode Text="后勤" Value="后勤"></asp:TreeNode>
                        <asp:TreeNode Text="工会" Value="工会"></asp:TreeNode>
                    </asp:TreeNode>
                    <asp:TreeNode Text="学年" Value="学年">
                        <asp:TreeNode Text="高一" Value="高一"></asp:TreeNode>
                        <asp:TreeNode Text="高二" Value="高二"></asp:TreeNode>
                        <asp:TreeNode Text="高三" Value="高三"></asp:TreeNode>
                    </asp:TreeNode>
                </Nodes>
                <NodeStyle Font-Names="Tahoma" ForeColor="Black" 
                    HorizontalPadding="0px" NodeSpacing="0px" VerticalPadding="0px" />
            </asp:TreeView>
            </form>
    </body></html>
      

  5.   

    本帖最后由 net_lover 于 2012-04-13 09:01:37 编辑
      

  6.   

    #TreeView1{padding:0; margin:0;}或者你查看源代码看看生成的html标签,找到treeview
      

  7.   

    ShowLines="true"    将treeview的ShowLines属性改为true,我之前也遇到过这样的问题,写样式写脚本都没解决掉后来把属性设置一下就好了!
      

  8.   

    微软的这个TreeView,会生成很多的table,td,是这些标记直接的空格导致的
      

  9.   

    本帖最后由 net_lover 于 2012-04-13 09:41:12 编辑
      

  10.   

    <%@ Page Language="C#" EnableViewState="true" %><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <head>
      <title></title>
      <style type="text/css">
        .tree td div
        {
          height: 20px !important;
        }
        *
        {
          padding: 0;
          margin: 0;
          border: 0;
        }
      </style>
    </head>
    <body>
      <form id="form1" runat="server" style="margin: 0px; padding: 0px;">
      <asp:TreeView ID="TreeView1" runat="server" ShowLines="True" CssClass="tree">
        <Nodes>
          <asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
          <asp:TreeNode Text="新建节点" Value="新建节点">
            <asp:TreeNode Text="新建节点" Value="新建节点">
              <asp:TreeNode Text="新建节点" Value="新建节点">
                <asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
              </asp:TreeNode>
            </asp:TreeNode>
            <asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
          </asp:TreeNode>
          <asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
          <asp:TreeNode Text="新建节点" Value="新建节点">
            <asp:TreeNode Text="新建节点" Value="新建节点">
              <asp:TreeNode Text="新建节点" Value="新建节点">
                <asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
              </asp:TreeNode>
            </asp:TreeNode>
          </asp:TreeNode>
          <asp:TreeNode Text="新建节点" Value="新建节点">
            <asp:TreeNode Text="新建节点" Value="新建节点"></asp:TreeNode>
          </asp:TreeNode>
        </Nodes>
      </asp:TreeView>
      </form>
    </body>
    </html> 
      

  11.   

    在net_lover的帮助下,胜利通过!