html折叠菜单列子,winform 折叠式菜单 示例源码 后台管理UI界面参考

【实例简介】

【实例截图】

339258b9e1e253a614d1f3b905fd00c8.png

【核心代码】

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

namespace MainUI

{

public partial class MainFrm : Form

{

public MainFrm()

{

InitializeComponent();

}

private void MainFrm_Load(object sender, EventArgs e)

{

CreateOutlookList();

}

private void CreateCarList()

{

listView1.Items.Clear();

listView1.LargeImageList = imageListCars;

listView1.Items.Add("Sports", 0);

listView1.Items.Add("Beetle", 1);

listView1.Items.Add("Vintage", 2);

}

private void CreateOutlookList()

{

listView1.Items.Clear();

listView1.LargeImageList = imageListOutlook;

listView1.Items.Add("Outlook Today", 0);

listView1.Items.Add("Inbox", 1);

listView1.Items.Add("Calendar", 2);

listView1.Items.Add("Contacts", 3);

listView1.Items.Add("Tasks", 4);

listView1.Items.Add("Deleted Items", 5);

}

private void CreateZipList()

{

listView1.Items.Clear();

listView1.LargeImageList = imageListZip;

listView1.Items.Add("Word Docs", 0);

listView1.Items.Add("Holiday Pics", 0);

listView1.Items.Add("C# programs", 0);

listView1.Items.Add("Samba Install", 0);

}

void ButtonClick(object sender, System.EventArgs e)

{

// Get the clicked button...

Button clickedButton = (Button)sender;

// ... and it's tabindex

int clickedButtonTabIndex = clickedButton.TabIndex;

// Send each button to top or bottom as appropriate

foreach (Control ctl in panel1.Controls)

{

if (ctl is Button)

{

Button btn = (Button)ctl;

if (btn.TabIndex > clickedButtonTabIndex)

{

if (btn.Dock != DockStyle.Bottom)

{

btn.Dock = DockStyle.Bottom;

// This is vital to preserve the correct order

btn.BringToFront();

}

}

else

{

if (btn.Dock != DockStyle.Top)

{

btn.Dock = DockStyle.Top;

// This is vital to preserve the correct order

btn.BringToFront();

}

}

}

}

// Determine which button was clicked.

switch (clickedButton.Text)

{

case "Cars":

CreateCarList();

break;

case "Outlook Shortcuts":

CreateOutlookList();

break;

case "Zip Files":

CreateZipList();

break;

}

listView1.BringToFront(); // Without this, the buttons will hide the items.

}

private void listView1_SelectedIndexChanged(object sender, EventArgs e)

{

if (this.listView1.SelectedIndices.Count > 0)

{

MessageBox.Show(this.listView1.SelectedItems[0].Text);

}

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值