简单控件开发实现图标按钮

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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;
using System.IO;
 
namespace RibbonBarCrl
{
    public partial class ButtonLeftControl : Control
    {
        private Image con = null;
 
        public ButtonLeftControl()
        {
            InitializeComponent();
            con = new Bitmap(Properties.Resources.ZoomIn1);
            this.MouseEnter += new EventHandler(UCSelectClassifyItem_MouseEnter);
            this.MouseLeave += new EventHandler(UCSelectClassifyItem_MouseLeave);
        }
 
        void UCSelectClassifyItem_MouseLeave(object sender, EventArgs e)
        {
            con = new Bitmap(Properties.Resources.ZoomIn1);
            Invalidate();
        }
 
        void UCSelectClassifyItem_MouseEnter(object sender, EventArgs e)
        {
            con = new Bitmap(Properties.Resources.InChange);
            Invalidate();
        }
 
        protected override void OnPaint(PaintEventArgs pe)
        {
            base.OnPaint(pe);
            Graphics graphics = pe.Graphics;
            graphics.DrawImage(con, new Rectangle(0, 0, this.Width, this.Height));
            graphics.Dispose();
        }
    }
}

 

posted @   之远  阅读(215)  评论(0编辑  收藏  举报
编辑推荐:
· 理解Rust引用及其生命周期标识(下)
· 从二进制到误差:逐行拆解C语言浮点运算中的4008175468544之谜
· .NET制作智能桌面机器人:结合BotSharp智能体框架开发语音交互
· 软件产品开发中常见的10个问题及处理方法
· .NET 原生驾驭 AI 新基建实战系列:向量数据库的应用与畅想
阅读排行:
· 2025成都.NET开发者Connect圆满结束
· 后端思维之高并发处理方案
· 千万级大表的优化技巧
· 在 VS Code 中,一键安装 MCP Server!
· 10年+ .NET Coder 心语 ── 继承的思维:从思维模式到架构设计的深度解析
点击右上角即可分享
微信分享提示