左侧收缩菜单

Posted jmy9

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了左侧收缩菜单相关的知识,希望对你有一定的参考价值。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinForm测试
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}

int panel1Height = 25;
int panel2Height = 200;
int panel3Height = 25;
int panel4Height = 150;
int panel5Height = 25;
int panel6Height = 100;
private void panel1_Click(object sender, EventArgs e)
{
if (panel2.Visible==true) //已显示容器2,需要隐藏容器2
{
panel2.Visible = false; //隐藏容器2,容器3和容器5就要移动到容器1之下
panel3.Top = panel1Height; //容器3移动到容器1之下
panel5.Top = panel1Height + panel3Height; //把容器5移动到容器3下
}else{ //已隐藏容器2,需要显示容器2
panel2.Visible = true; //显示容器2
panel2.Top = panel1Height; //容器2放在容器1之下
panel3.Top = panel1Height + panel2Height; //容器3放在容器2之下
panel4.Visible = false;
panel6.Visible = false;
panel5.Top = panel1Height + panel2Height + panel3Height; //把容器5让在容器3之下
}
}

private void panel3_Click(object sender, EventArgs e)
{
panel3.Top = panel1Height;
if (panel4.Visible == true)
{
panel4.Visible = false;
panel5.Top = panel1Height + panel3Height;
}
else
{
panel4.Visible = true;
panel2.Visible = false;
panel6.Visible = false;
panel4.Top = panel1Height + panel3Height;
panel5.Top = panel1Height + panel3Height + panel4Height;
}
}

private void panel5_Click(object sender, EventArgs e)
{
panel3.Top = panel1Height;
panel5.Top = panel1Height+panel3Height;
if (panel6.Visible == true)
{
panel6.Visible = false;
}
else
{
panel6.Visible = true;
panel2.Visible = false;
panel4.Visible = false;
panel6.Top = panel1Height+panel3Height+panel5Height;
}
}


}
}

以上是关于左侧收缩菜单的主要内容,如果未能解决你的问题,请参考以下文章

jquery实现后台系统左侧菜单的点击展开/收缩二级菜单效果

c# winform 怎么弄展开收缩的左边菜单 功能 急 在线等

当 UISplitViewController 上的菜单滑动时,收缩细节视图控制器动画

二级菜单打开后页面刷新不收缩效果

jQuery动态添加多级收缩菜单

只用CSS能否制作可以收缩的下拉菜单