C# 可折叠导航

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Windows.Forms;  
  9.   
  10. namespace WindowsFormsApplication2  
  11. {  
  12.     public partial class Form1 : Form  
  13.     {  
  14.         public Form1()  
  15.         {  
  16.             InitializeComponent();  
  17.         }  
  18.         private Font ft = new Font("黑体",12);  
  19.         private static Panel iPanel= new Panel();  
  20.         private static PictureBox iPict =new PictureBox();  
  21.   
  22.         private void Form1_Load(object sender, EventArgs e)  
  23.         {  
  24.             pictureBox1.Image = global::WindowsFormsApplication2.Properties.Resources.朝上按钮;  
  25.             pictureBox1.Size = global::WindowsFormsApplication2.Properties.Resources.朝上按钮.Size;  
  26.             pictureBox2.Image = global::WindowsFormsApplication2.Properties.Resources.朝上按钮;  
  27.             pictureBox2.Size = global::WindowsFormsApplication2.Properties.Resources.朝上按钮.Size;  
  28.             ft = label1.Font;  
  29.         }  
  30.   
  31.         private void label1_MouseEnter(object sender, EventArgs e)  
  32.         {  
  33.             ((Label)sender).ForeColor = Color.Red;//设置控件文字字颜色  
  34.             ((Label)sender).Font = new Font(ft, ft.Style | FontStyle.Underline);//设置控件字体  
  35.         }  
  36.   
  37.         private void label1_MouseLeave(object sender, EventArgs e)  
  38.         {  
  39.             ((Label)sender).ForeColor = Color.Black;//设置控件文字颜色  
  40.             ((Label)sender).Font = new Font(ft, ft.Style); //设置控件字体  
  41.         }  
  42.   
  43.         private void pictureBox1_Click(object sender, EventArgs e)  
  44.         {  
  45.             int i = Convert.ToInt16(((PictureBox)sender).Tag.ToString());  
  46.             switch (i)  
  47.             {  
  48.                 case 1:  
  49.                     iPanel = panel2_1;  
  50.                     iPict = pictureBox1;  
  51.                     break;  
  52.                 case 2:  
  53.                     iPanel = panel2_2;  
  54.                     iPict = pictureBox2;  
  55.                     break;  
  56.             }  
  57.   
  58.             if (Convert.ToInt16(iPanel.Tag.ToString()) == 1)  
  59.             {  
  60.                 iPanel.Tag = 2;  
  61.                 iPict.Image = Properties.Resources.朝上按钮;  
  62.                 iPanel.Visible = true;  
  63.             }  
  64.             else  
  65.             {  
  66.                 iPanel.Tag = 1;  
  67.                 iPict.Image = Properties.Resources.朝下按钮;  
  68.                 iPanel.Visible = false;  
  69.             }  
  70.         }  
  71.     }  
  72. }  


转载自:http://blog.youkuaiyun.com/mghc00100/article/details/7821732http://blog.youkuaiyun.com/mghc00100/article/details/7821732

另可参考:http://blog.youkuaiyun.com/bdmh/article/details/7549140

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值