基本信息
源码名称:winform 折叠式菜单 示例源码 后台管理UI界面参考
源码大小:0.05M
文件格式:.rar
开发语言:C#
更新时间:2014-01-25
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍

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);
            }
        }
    }
}