C#仿WINDOWS可折叠导航栏
昨天晚上看见了个帖子,野比小王子在2楼留下下了版主的http://blog.csdn.net/bdmh/article/details/7549140 ,今天下午没事做,自己也搞了一下,效果 不怎么好(窗体中有5个panel控件,设置其中4个的DOCK属性为TOP,具体见源码)。废话不多说,代码如下:
- C# code
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication2{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private Font ft = new Font("黑体",12); private static Panel iPanel= new Panel(); private static PictureBox iPict =new PictureBox(); private void Form1_Load(object sender, EventArgs e) { pictureBox1.Image = global::WindowsFormsApplication2.Properties.Resources.朝上按钮; pictureBox1.Size = global::WindowsFormsApplication2.Properties.Resources.朝上按钮.Size; pictureBox2.Image = global::WindowsFormsApplication2.Properties.Resources.朝上按钮; pictureBox2.Size = global::WindowsFormsApplication2.Properties.Resources.朝上按钮.Size; ft = label1.Font; } private void label1_MouseEnter(object sender, EventArgs e) { ((Label)sender).ForeColor = Color.Red;//设置控件文字字颜色 ((Label)sender).Font = new Font(ft, ft.Style | FontStyle.Underline);//设置控件字体 } private void label1_MouseLeave(object sender, EventArgs e) { ((Label)sender).ForeColor = Color.Black;//设置控件文字颜色 ((Label)sender).Font = new Font(ft, ft.Style); //设置控件字体 } private void pictureBox1_Click(object sender, EventArgs e) { int i = Convert.ToInt16(((PictureBox)sender).Tag.ToString()); switch (i) { case 1: iPanel = panel2_1; iPict = pictureBox1; break; case 2: iPanel = panel2_2; iPict = pictureBox2; break; } if (Convert.ToInt16(iPanel.Tag.ToString()) == 1) { iPanel.Tag = 2; iPict.Image = Properties.Resources.朝上按钮; iPanel.Visible = true; } else { iPanel.Tag = 1; iPict.Image = Properties.Resources.朝下按钮; iPanel.Visible = false; } } }}
[解决办法]
[解决办法]
推荐哦
推荐哦
cao版主要推荐哦
[解决办法]
C#无敌,微软雄霸天下
[解决办法]
看到努力的影子了,再努力努力研究研究.