当前位置:网站首页>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
边栏推荐
- 传统企业如何转型社交电商,泰山众筹的玩法有哪些?
- 多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG
- 2022 the first of the new league henan (4) : zhengzhou university of light industry G - maze
- Interface Test Framework Practice (4) | Get Schema Assertion
- Assembly answers
- 数值类型转换02
- WebSocket的实际应用
- IDEC和泉触摸屏维修HG2F-SS22V HG4F软件通信分析
- 【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
- 2022/08/02 Study Notes (day22) Multithreading
猜你喜欢
12.机器学习基础:评估机器学习模型
StarRocks July Community Update
Shell之条件语句
"Obs" start pushing flow failure: the Output. The StartStreamFailed call process
Windows 安装PostgreSQL
Live | StarRocks technology insider: low base dictionary global optimization
How to prepare for the test interface test data
如何利用 Flutter 实现炫酷的 3D 卡片和帅气的 360° 展示效果
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
随机推荐
c语言结构体中的冒泡排序
【Harmony OS】【ARK UI】轻量级数据存储
寄存器(内存访问)
mysql bool盲注
Jmeter 模拟多用户登录的两种方法
JS底层手写
2.何为张量
测开:项目管理模块-项目curd开发
Where is the value of testers
Assembly answers
5.回顾简单的神经网络
Browser listens for tab closing
The flink sql task is changed, and after adding several fields to the sql, an error occurs when restoring from the previously saved savepoint.
接口测试框架实战(二)| 接口请求断言
How many moments have you experienced the collapse of electronic engineers?
数字化时代,企业如何建立自身的云平台与商业模式的选择?
t conditional judgment statement and if loop
索引创建、删除与使用
v-on指令:为元素绑定事件
如何利用 Flutter 实现炫酷的 3D 卡片和帅气的 360° 展示效果