当前位置: 首页 > news >正文

WinForm开发-自定义组件-1. 工具栏: UcompToolStrip

这里写自定义目录标题

  • 1. 工具栏: UcompToolStrip
    • 1.1 展示效果
    • 1.2 代码
      • UcompToolStrip.cs
      • UcompToolStrip.Designer.cs

1. 工具栏: UcompToolStrip

自定义一些Winform组件

1.1 展示效果

1)使用效果


2)控件事件
在这里插入图片描述

1.2 代码

  1. 设计
    在这里插入图片描述
  2. 编码

UcompToolStrip.cs

 public partial class UcompToolStrip : ToolStrip{// 定义委托类型public delegate void AddEventHandler(object sender, EventArgs e);public delegate void DeleteEventHandler(object sender, EventArgs e);public delegate void EditEventHandler(object sender, EventArgs e);public delegate void RefreshEventHandler(object sender, EventArgs e);public delegate void QueryEventHandler(object sender, EventArgs e);public delegate void QueryAdvEventHandler(object sender, EventArgs e);// 定义事件[Category("自定义事件")][Description("Button事件: 新增")]public event AddEventHandler UcEventOnAdd;[Category("自定义事件")][Description("Button事件: 删除")]public event DeleteEventHandler UcEventOnDelete;[Category("自定义事件")][Description("Button事件: 编辑")]public event EditEventHandler UcEventOnEdit;[Category("自定义事件")][Description("Button事件: 刷新")]public event RefreshEventHandler UcEventOnRefresh;[Category("自定义事件")][Description("Button事件: 查询")]public event QueryEventHandler UcEventOnQuery;[Category("自定义事件")][Description("Button事件: 高级查询")]public event QueryAdvEventHandler UcEventOnQueryAdv;public UcompToolStrip(){InitializeComponent();}public UcompToolStrip(IContainer container){container.Add(this);InitializeComponent();}// 为 ToolStripButton 添加 Click 事件处理程序        // 定义事件处理方法private void tsbtnAdd_Click(object sender, EventArgs e){            // 调用自定义事件UcEventOnAdd?.Invoke(this, e);// 在这里编写按钮点击时的逻辑//MessageBox.Show("新增");}private void tsbtnEdit_Click(object sender, EventArgs e){// 调用自定义事件UcEventOnEdit?.Invoke(this, e);}private void tsbtnDel_Click(object sender, EventArgs e){// 调用自定义事件UcEventOnDelete?.Invoke(this, e);}private void tsbtnRefresh_Click(object sender, EventArgs e){// 调用自定义事件UcEventOnRefresh?.Invoke(this, e);}private void tsbtnQuery_Click(object sender, EventArgs e){// 调用自定义事件UcEventOnQuery?.Invoke(this, e);}private void tsbtnQueryAdv_Click(object sender, EventArgs e){// 调用自定义事件UcEventOnQueryAdv?.Invoke(this, e);}}

UcompToolStrip.Designer.cs

...... 省略this.toolStripSeparator2,this.tsbtnQueryAdv});this.Size = new System.Drawing.Size(100, 34);this.ResumeLayout(false);// 增加按钮事件this.tsbtnAdd.Click += new System.EventHandler(this.tsbtnAdd_Click);this.tsbtnEdit.Click += new System.EventHandler(this.tsbtnEdit_Click);this.tsbtnDel.Click += new System.EventHandler(this.tsbtnDel_Click);this.tsbtnRefresh.Click += new System.EventHandler(this.tsbtnRefresh_Click);this.tsbtnQuery.Click += new System.EventHandler(this.tsbtnQuery_Click);this.tsbtnQueryAdv.Click += new System.EventHandler(this.tsbtnQueryAdv_Click);}#endregionprivate System.Windows.Forms.ToolStripButton tsbtnAdd;private System.Windows.Forms.ToolStripButton tsbtnEdit;private System.Windows.Forms.ToolStripButton tsbtnDel;private System.Windows.Forms.ToolStripButton tsbtnRefresh;private System.Windows.Forms.ToolStripButton tsbtnQuery;private System.Windows.Forms.ToolStripButton tsbtnQueryAdv;private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;private System.Windows.Forms.ToolStripLabel tslblKeyWord;private System.Windows.Forms.ToolStripTextBox tstxtInputKeyword;        private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
http://www.lryc.cn/news/515760.html

相关文章:

  • 法律专业legal case的留学论文写作技巧分析(1)
  • 2025编程技术前沿:探索最新的开发工具与趋势
  • sqlserver sql转HTMM邮件发送
  • GeoTrust True BusinessID Wildcard
  • R语言的数据结构
  • 安装和配置MySQL教程
  • 黑马Java面试教程_P10_设计模式
  • 043_小驰私房菜_MTK Camera,Hal层将camera型号写到property属性中
  • 基础图形化界面的一个图片爬虫期末
  • Outlook2024版如何回到经典Outlook
  • 仿生的群体智能算法总结之二(十种)
  • SpringBoot入门之创建一个Hello World项目
  • MySQL与标准SQL的区别
  • docker中使用Dockerfile设置Volume挂载点
  • Samsung手机首次主要采用竞对Micron LPDDR5内存
  • 【项目开发】C#环境配置及VScode运行C#教程(学生管理系统)
  • [241231] CachyOS 2024 年终总结:性能飞跃与社区繁荣 | ScyllaDB 宣布转向开源可用许可证
  • AI-Talk开发板之超拟人
  • Swift Concurrency(并发)学习
  • 从0开始的opencv之旅(1)cv::Mat的使用
  • Hoverfly 任意文件读取漏洞(CVE-2024-45388)
  • 详解网络管理
  • iOS 11 中的 HEIF 图像格式 - 您需要了解的内容
  • 深入AIGC领域:ChatGPT开发者获取OpenAI API Key的实用指南
  • 软件工程实验-实验2 结构化分析与设计-总体设计和数据库设计
  • 密码学精简版
  • 开源模型迎来颠覆性突破:DeepSeek-V3与Qwen2.5如何重塑AI格局?
  • 【51单片机零基础-chapter4:LED数码管】
  • 【网络】什么是路由协议(Routing Protocols)?常见的路由协议包括RIP、OSPF、EIGRP和BGP
  • Unity3D ILRuntime开发原则与接口绑定详解