- 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;
- }
- }
- }
- }
另可参考:http://blog.youkuaiyun.com/bdmh/article/details/7549140