当前位置:网站首页>Secondary development of WinForm controls
Secondary development of WinForm controls
2022-08-03 04:40:00 【ViperL1】
One, the input field is not empty verification
① First of all, create a class library, and then add an additional component class
in it②Add a reference to the control namespace in the class library (System.Windows.Forms)
3 Change the base class to the control that needs to be inherited (such as TextBox)
public partial class SuperTextBox : TextBox
④ Drag and drop errorProvider
in the editing area⑤ Write a warning method and associate an error message
public bool CheckEmpty(){if(this.Text==""){this.errorProvider.SetError(this,"cannot be empty"); //Subordinate component, reminding contentreturn true}else{this.errorProvider.SetError(this,empty);return false;}}
⑥ ⑥It can be applied directly in the project by the method of ordinary controls
also must be called CheckEmpty(); in the function body for it to take effect.
Second, use regular expressions to achieve complex verification
Based on the above project, rewrite the verification method
public bool BeginCheckData(string regularExpress, string errorMsg){if(CheckEmpty() == false)return false;Regex objRegex = new Regex(regularExpress,RegexOptions.IgnoreCase); //Ignore caseif(!objRegex.IsMatch(this.Text)){this.errorProvider.SetError(this, "verification failed");return true}else{this.errorProvider.SetError(this,empty);return false;}}
Three, other programs call custom controls
Move the .dll code generated by the control scheme to the project that needs to be called, and then reference it in the toolbox
边栏推荐
- 8.电影评论分类:二分类问题
- 2022河南萌新联赛第(四)场:郑州轻工业大学 E - 睡大觉
- 社交电商:流量红利已尽,裂变营销是最低成本的获客之道
- 工程制图-齿轮
- Bubble sort in c language structure
- Two ways to simulate multi-user login in Jmeter
- I ported GuiLite to STM32F4 board
- Kotlin-Flow常用封装类:StateFlow的使用
- Browser listens for tab closing
- Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
猜你喜欢
How to use the interface management tool YApi?Beautiful, easy to manage, super easy to use
移动流量的爆发式增长,社交电商如何选择商业模式
"Obs" start pushing flow failure: the Output. The StartStreamFailed call process
【软件工程之美 - 专栏笔记】35 | 版本发布:软件上线只是新的开始
2022/08/02 Study Notes (day22) Multithreading
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
接口测试框架实战(四)| 搞定 Schema 断言
unity2D横板游戏教程6-敌人AI以及受击动画
Oracle EMCC可以独立安装吗?还是必须安装到数据库服务器上?
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
随机推荐
Jmeter 模拟多用户登录的两种方法
如何利用 Flutter 实现炫酷的 3D 卡片和帅气的 360° 展示效果
js garbage collection mechanism
多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG
2022/08/02 学习笔记 (day22) 多线程
Interface testing framework of actual combat (2) | interface request assertion
2.何为张量
传统企业如何转型社交电商,泰山众筹的玩法有哪些?
LeetCode算法日记:面试题 03.04. 化栈为队
链动2+1模式简单,奖励结构丰厚,自主裂变?
3.张量运算
Shell编程的条件语句
修饰生物素DIAZO-生物素-PEG3-DBCO|重氮-生物素-三聚乙二醇-二苯基环辛炔
2022 the first of the new league henan (4) : zhengzhou university of light industry G - maze
SM30 表维护视图数据保存前 数据校验事件
closures in js
v-on指令:为元素绑定事件
软件开发的最大的区别是什么?
Problems that need to be solved for interrupting the system
Windows 安装PostgreSQL