Winform 控件 errorProvider 的常用属性和方法

来源:互联网 发布:数据库恢复 编辑:程序博客网 时间:2024/05/10 09:53
今天在看代码时发现了errorProvider   这个控件,不知道怎么用,后来查了下,发现messageBox  提示错误信息要好的多,下面就是些常用的属性和方法的实例,列举的只是比较常用的!
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 ErrorProviderDemo{    public partial class Form1 : Form    {        public Form1()        {            InitializeComponent();            //设置其闪烁样式            //BlinkIfDifferentError 当图标已经显示并且为控件设置了新的错误字符串时闪烁。             //AlwaysBlink 总是闪烁。             //NeverBlink 错误图标从不闪烁。            this.errorProvider1.BlinkStyle = ErrorBlinkStyle.AlwaysBlink;            //错误图标的闪烁速率(以毫秒为单位)。默认为 250 毫秒            this.errorProvider1.BlinkRate = 500;        }        private void btnSubmit_Click(object sender, EventArgs e)        {            if (this.txtName.Text == "" )            {                ///SetError 设置指定控件的错误描述字符串                this.errorProvider1.SetError(this.txtName, "name is not null");            }            if (this.txtNum.Text == "")            {                this.errorProvider1.SetError(this.txtNum, "num is not null");            }        }    }}

0 0
原创粉丝点击