《Microsoft Visual C# .NET 2003开发技巧大全》源代码

源代码在线查看: 8.12.txt

软件大小: 288 K
上传用户: rylzll
关键词: Microsoft Visual 2003 NET
下载地址: 免注册下载 普通下载 VIP

相关代码

				Listing 8.12 Displaying Errors with ErrorProvider
				private void tbPhone_Validated(object sender, System.EventArgs e)
				{
				Regex phoneExp = new Regex( @”^\(\d{3}\)\s\d{3}-\d{4}$” );
				if( tbPhone.Text == “” )
				{
				errorProvider1.SetError( tbPhone, “Please enter a phone number” );
				}
				else if( phoneExp.Match( tbPhone.Text ).Success == false )
				{
				errorProvider1.SetError( tbPhone, “Invalid Phone Number” );
				}
				else
				{
				errorProvider1.SetError( tbPhone, “” );
				}
				}
				private void tbFirstName_Validated(object sender, System.EventArgs e)
				{
				// clear error if they filled in first name
				if( tbFirstName.Text != “” )
				errorProvider1.SetError( tbFirstName, “” );
				}
				private void tbLastName_Validated(object sender, System.EventArgs e)
				{
				// clear error since control is validated
				errorProvider1.SetError( tbLastName, “” );
				}			

相关资源