如何做类似OICQ、OutLook那样上下伸缩展开的菜单?
谢谢。

解决方案 »

  1.   

    楼主可以去www.codeproject.com找找,有很多开源的控件。
      

  2.   

    http://www.cnblogs.com/tanjunmail/archive/2005/03/22/66556.aspx
      

  3.   

    就是OICQ面板上,好友、陌生人、很名单这种菜单,点击一下,会展开它下面的每个人。
      

  4.   

    <script language="javascript">
    function SetTd(tr)
    {
    var hdnPara = document.all("hdnPara");
    var hideTr = document.all(hdnPara.value);
    var displayTr = document.all(tr);
    hdnPara.value = tr;
    hideTr.style.display = "none";
    displayTr.style.display = "inline";
    }
    function DisplayDiv(option)
    {
    var workerDiv = document.all("workerDiv");
    var divLeft,divTop;
    if(option == 1) divTop = window.event.y + document.body.scrollTop + 20;
    else  divTop = window.event.y + document.body.scrollTop -200;
    divLeft = window.event.x + document.body.scrollLeft - 150;
    workerDiv.style.left = divLeft;
    workerDiv.style.top = divTop;
    workerDiv.style.display = "inline";
    }</script>
    <input type="hidden" id="hdnPara" value="detail1">
    <table width="191" border="0" cellpadding="0" cellspacing="0">
    <tr height="30"><td id="ban1" onClick="SetTd('detail1');" style="cursor:hand">
    aaa</td></tr>
    <tr id="detail1" style="display:inline"><td height="179">111</td></tr>
    <tr height="29"><td id="ban1" onClick="SetTd('detail2');" style="cursor:hand" >
    bbb</td></tr>
    <tr id="detail2" style="display:none"><td background="images/content.gif" height="179">
    222</td></tr>
        <tr height="30"><td id="ban1" onClick="SetTd('detail3');" style="cursor:hand">
    ccc</td></tr>
    <tr id="detail3" style="display:none"><td background="images/content.gif" height="179">
    333</td></tr>
    <tr height="28"><td id="ban1" onClick="SetTd('detail4');" style="cursor:hand" >
    ddd</td></tr>
    <tr id="detail4" style="display:none"><td background="images/content.gif" height="179">
    444</td></tr>
    <tr height="29"><td id="ban1" onClick="SetTd('detail5');" style="cursor:hand" >
    eee</td></tr>
    <tr id="detail5" style="display:none"><td background="images/content.gif" height="179">
    555</td></tr>
    <tr height="30"><td id="ban1" onClick="SetTd('detail6');" style="cursor:hand" ></td></tr>
    <tr id="detail6" style="display:none"><td background="images/content.gif" height="179">
    666</td></tr>
    </table>
      

  5.   

    这个<script language="javascript">
    function SetTd(tr)
    {
    var hdnPara = document.all("hdnPara");
    var hideTr = document.all(hdnPara.value);
    var displayTr = document.all(tr);
    hdnPara.value = tr;
    hideTr.style.display = "none";
    displayTr.style.display = "inline";
    }</script>
    <input type="hidden" id="hdnPara" value="detail1">
    <table width="191" border="0" cellpadding="0" cellspacing="0">
    <tr height="30"><td id="ban1" onClick="SetTd('detail1');" style="cursor:hand">
    aaa</td></tr>
    <tr id="detail1" style="display:inline"><td height="179">111</td></tr>
    <tr height="29"><td id="ban1" onClick="SetTd('detail2');" style="cursor:hand" >
    bbb</td></tr>
    <tr id="detail2" style="display:none"><td background="images/content.gif" height="179">
    222</td></tr>
        <tr height="30"><td id="ban1" onClick="SetTd('detail3');" style="cursor:hand">
    ccc</td></tr>
    <tr id="detail3" style="display:none"><td background="images/content.gif" height="179">
    333</td></tr>
    <tr height="28"><td id="ban1" onClick="SetTd('detail4');" style="cursor:hand" >
    ddd</td></tr>
    <tr id="detail4" style="display:none"><td background="images/content.gif" height="179">
    444</td></tr>
    <tr height="29"><td id="ban1" onClick="SetTd('detail5');" style="cursor:hand" >
    eee</td></tr>
    <tr id="detail5" style="display:none"><td background="images/content.gif" height="179">
    555</td></tr>
    </table>
      

  6.   

    这个很简单呀,利用javascript就可以做到呀!!!
      

  7.   

    ComponentArt 控件就可以。
      

  8.   

    ComponentArt 控件就可以。
      

  9.   

    楼上的详细讲讲ComponentAtr怎么用,谢谢!
      

  10.   

    javascript,我这里有代码!去年做办公系统时做的!
      

  11.   

    postfix2也给我一份,谢谢!
    [email protected]
      

  12.   

    postfix2也给我一份,谢谢!
    [email protected]
      

  13.   

    //1.前台html代码
    <%@ Control Language="c#" AutoEventWireup="false" Codebehind="Left.ascx.cs" Inherits="Document.UserControl.Home.Left" TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    <STYLE type="text/css">
    A:link { COLOR: #000000; FONT-SIZE: 12px; TEXT-DECORATION: none}
    A:visited { COLOR: #000000; FONT-SIZE: 12px; TEXT-DECORATION: none}
    A:hover { COLOR: #006CD9; FONT-SIZE: 12px; TEXT-DECORATION: none}
    BODY { FONT-SIZE: 12px;}
    TD { FONT-SIZE: 12px; line-height: 150%}
    </STYLE>
    <script language="JavaScript">
    <!--
    function showitem(id,name)
    {
    //return ("<span><a href='"+id+"' target=_blank>"+name+"</a></span><br>")
    return ("<span><a href='#' onclick=\"url('"+id+"');\">"+name+"</a></span><br>")
    }
    function url(id)
    {
    var source = document.getElementById('fMain');
    source.src=id;
    }
    function switchoutlookBar(number)
    {
    var i = outlookbar.opentitle;
    outlookbar.opentitle=number;
    var id1,id2,id1b,id2b
    if (number!=i && outlooksmoothstat==0){
    if (number!=-1)
    {
    if (i==-1){
    id2="blankdiv";
    id2b="blankdiv";
    }
    else{
    id2="outlookdiv"+i;
    id2b="outlookdivin"+i;
    document.all("outlooktitle"+i).style.border="1px none navy";
    document.all("outlooktitle"+i).style.background=outlookbar.maincolor;
    document.all("outlooktitle"+i).style.color="#ffffff";
    document.all("outlooktitle"+i).style.textalign="center";
    }
    id1="outlookdiv"+number
    id1b="outlookdivin"+number
    document.all("outlooktitle"+number).style.border="1px none white";
    document.all("outlooktitle"+number).style.background=outlookbar.maincolor; //title
    document.all("outlooktitle"+number).style.color="#ffffff";
    document.all("outlooktitle"+number).style.textalign="center";
    smoothout(id1,id2,id1b,id2b,0);
    }
    else
    {
    document.all("blankdiv").style.display="";
    document.all("blankdiv").sryle.height="100%";
    document.all("outlookdiv"+i).style.display="none";
    document.all("outlookdiv"+i).style.height="0%";
    document.all("outlooktitle"+i).style.border="1px none navy";
    document.all("outlooktitle"+i).style.background=outlookbar.maincolor;
    document.all("outlooktitle"+i).style.color="#ffffff";
    document.all("outlooktitle"+i).style.textalign="center";
    }
    }
    }
    function smoothout(id1,id2,id1b,id2b,stat)
    {
    if(stat==0){
    tempinnertext1=document.all(id1b).innerHTML;
    tempinnertext2=document.all(id2b).innerHTML;
    document.all(id1b).innerHTML="";
    document.all(id2b).innerHTML="";
    outlooksmoothstat=1;
    document.all(id1b).style.overflow="hidden";
    document.all(id2b).style.overflow="hidden";
    document.all(id1).style.height="0%";
    document.all(id1).style.display="";
    setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+outlookbar.inc+")",outlookbar.timedalay);
    }
    else
    {
    stat+=outlookbar.inc;
    if (stat>100)
    stat=100;
    document.all(id1).style.height=stat+"%";
    document.all(id2).style.height=(100-stat)+"%";
    if (stat<100) 
    setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+stat+")",outlookbar.timedalay);
    else
    {
    document.all(id1b).innerHTML=tempinnertext1;
    document.all(id2b).innerHTML=tempinnertext2;
    outlooksmoothstat=0;
    document.all(id1b).style.overflow="auto";
    document.all(id2).style.display="none";
    }
    }
    }
    function getOutLine()
    {
    outline="<table "+outlookbar.otherclass+">";
    for (i=0;i<(outlookbar.titlelist.length);i++)
    {
    outline+="<tr><td name=outlooktitle"+i+" id=outlooktitle"+i+" "; 
    if (i!=outlookbar.opentitle) 
    outline+=" nowrap align=center style='cursor:hand;background-color:"+outlookbar.maincolor+";color:#ffffff;height:20;border:1 none navy' ";
    else
    outline+=" nowrap align=center style='cursor:hand;background-color:"+outlookbar.maincolor+";color:white;height:20;border:1 none white' ";
    outline+=outlookbar.titlelist[i].otherclass
    outline+=" onclick='switchoutlookBar("+i+")'><span class=smallFont>";
    outline+=outlookbar.titlelist[i].title+"</span></td></tr>";
    outline+="<tr><td name=outlookdiv"+i+" valign=top align=center id=outlookdiv"+i+" style='width:100%"
    if (i!=outlookbar.opentitle) 
    outline+=";display:none;height:0%;";
    else
    outline+=";display:;height:100%;";
    outline+="'><div name=outlookdivin"+i+" id=outlookdivin"+i+" style='overflow:auto;width:100%;height:100%'>";
    for (j=0;j<outlookbar.itemlist[i].length;j++)
    outline+=showitem(outlookbar.itemlist[i][j].key,outlookbar.itemlist[i][j].title);
    outline+="</div></td></tr>"
    }
    outline+="</table>"
    return outline
    }
    function show()
    {
    var outline;
    outline="<div id=outLookBarDiv name=outLookBarDiv style='width=100%;height:100%'>"
    outline+=outlookbar.getOutLine();
    outline+="</div>"
    document.write(outline);
    }
    function theitem(intitle,instate,inkey)
    {
    this.state=instate;
    this.otherclass=" nowrap ";
    this.key=inkey;
    this.title=intitle;
    }
    function addtitle(intitle)
    {
    outlookbar.itemlist[outlookbar.titlelist.length]=new Array();
    outlookbar.titlelist[outlookbar.titlelist.length]=new theitem(intitle,1,0);
    return(outlookbar.titlelist.length-1);
    }
    function additem(intitle,parentid,inkey)
    {
    if (parentid>=0 && parentid<=outlookbar.titlelist.length)
    {
    outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length]=new theitem(intitle,2,inkey);
    outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length-1].otherclass=" nowrap align=left style='height:5' ";
    return(outlookbar.itemlist[parentid].length-1);
    }
    else
    additem=-1;
    }
    function outlook()
    {
    this.titlelist=new Array();
    this.itemlist=new Array();
    this.divstyle="style='height:100%;width:100%;overflow:auto' align=center";//可以在这里设置对齐方式
    this.otherclass="border=0 cellspacing='0' cellpadding='0' style='height:100%;width:100%'valign=middle align=center ";
    this.addtitle=addtitle;
    this.additem=additem;
    this.starttitle=-1;
    this.show=show;
    this.getOutLine=getOutLine;
    this.opentitle=this.starttitle;
    this.reflesh=outreflesh;
    this.timedelay=50;
    this.inc=10;
    this.maincolor = "#336699"
    }
    function outreflesh()
    {
    document.all("outLookBarDiv").innerHTML=outlookbar.getOutLine();
    }
    function locatefold(foldname)
    {
    if (foldname=="")
    foldname = outlookbar.titlelist[0].title
    for (var i=0;i<outlookbar.titlelist.length;i++)
    {
    if(foldname==outlookbar.titlelist[i].title)
    {
    outlookbar.starttitle=i;
    outlookbar.opentitle=i;
    }
    }
    }
    var outlookbar=new outlook();
    var tempinnertext1,tempinnertext2,outlooksmoothstat
    outlooksmoothstat = 0;<%=LoadVerticalMenu()%>//从数据库产生垂直菜单//-->
    </script>
    <table id="mnuList" style="WIDTH:150px;HEIGHT: 100%" cellspacing="0" cellpadding="0" align="left"
    border="0">
    <tr>
    <td bgcolor="#F0F0E5" id="outLookBarShow" style="HEIGHT: 100%" valign="top" align="middle"
    name="outLookBarShow">
    <script language="JavaScript">
    <!--
    locatefold("")
    outlookbar.show() 
    //-->
    </script>
    </td>
    </tr>
    </table>
      

  14.   

    //2.后天cs代码
    namespace Document.UserControl.Home
    {
    using System;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls; /// <summary>
    /// Summary description for Left.
    /// </summary>
    public class Left : System.Web.UI.UserControl
    { private void Page_Load(object sender, System.EventArgs e)
    {
    // Put user code to initialize the page here
    } #region Web Form Designer generated code
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: This call is required by the ASP.NET Web Form Designer.
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InitializeComponent()
    {
    this.Load += new System.EventHandler(this.Page_Load);
    }
    #endregion protected string LoadVerticalMenu()
    {
    string sqlFather="select * from PowerSetting where IsBoot=1";
    DataSet dsFather=Document.DataHelper.GetDataSet(sqlFather); string menu=""; for(int m=0;m<dsFather.Tables[0].Rows.Count;m++)
    {
    menu+="var t;";
    menu+="t=outlookbar.addtitle('"+dsFather.Tables[0].Rows[m]["Description"]+"');";
    string sqlChild="select * from PowerSetting where ParentID="+Convert.ToInt32(dsFather.Tables[0].Rows[m]["ParentID"])+" and IsBoot=0";
    DataSet dsChild=Document.DataHelper.GetDataSet(sqlChild);
    for(int i=0;i<dsChild.Tables[0].Rows.Count;i++)
    {
    menu+="outlookbar.additem('"+dsChild.Tables[0].Rows[i]["Description"]+"',t,'"+dsChild.Tables[0].Rows[i]["Url"]+"');";
    }
    }
    return menu;
    }
    }
    }
      

  15.   

    //3.数据库结构
    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[PowerSetting]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
    drop table [dbo].[PowerSetting]
    GOCREATE TABLE [dbo].[PowerSetting] (
    [PowerSettingID] [int] IDENTITY (1, 1) NOT NULL ,
    [ParentID] [int] NOT NULL ,
    [Description] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
    [Icon] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    [Url] [nvarchar] (255) COLLATE Chinese_PRC_CI_AS NULL ,
    [Target] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    [CreateByID] [nvarchar] (50) COLLATE Chinese_PRC_CI_AS NULL ,
    [CreateON] [datetime] NULL ,
    [IsEnabled] [bit] NULL ,
    [IsBoot] [int] NULL 
    ) ON [PRIMARY]
    GO
      

  16.   

    WakiCoolBar for asp.net 2.0 是适合于微软.Net开发平台的Web控件。它能放进Web 
    工具箱中,并可拖入 WEB 页面进行可视化的设置。只需设置菜单属性,几分钟时间,即可获得一个漂亮的类 Outlook 样式的菜单。各种页面效果均可通过控件属性来调节,使用者根 
    本无需会 Javascript,一样可以实现专业漂亮的菜单界面。
    控件2.0版主要更新:
    1.新增设置控件背景图片属性(BackGround),并可设置背景图片的显示位置及重复模式。 2.新增四种皮肤效果作为设置参考,可完全自行修改而做出新的皮肤效果来。
    3.新增Panels属性,可以方便地在IDE环境中进行可视化地添加菜单项,简单快捷,比设置XML文档更方便。同时为兼容1.0版,保留了设置XML的方式,可设置属性PanelSrc。
    4.为动态控制菜单的显示项,如不同权限显示不同的菜单,特新增了数据库绑定功能,只要将数据表按特定的方式进行整理,就可以进行自动绑定选择出的DataSet。控件效果地址:http://www.aspxcontrol.com/wakicoolbar/cn/sample.aspx
    下载地址:http://www.aspxcontrol.com/download/wakicoolbar.rar