📄 add.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Text.RegularExpressions;
namespace MailTo
{
public partial class add : Form
{
public add()
{
InitializeComponent();
}
public string email;
private void button1_Click(object sender, EventArgs e)
{
Regex myreg=new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"); //email验证
if (myreg.IsMatch(textBox1.Text))
{
email = textBox1.Text;
this.DialogResult = DialogResult.OK;
}
else
{
textBox1.Text = "";
msg.Text = "邮箱格式不正确,请重新输入!";
this.DialogResult = DialogResult.None;
}
}
private void button2_Click(object sender, EventArgs e)
{
this.DialogResult = DialogResult.Cancel;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
msg.Text = "";
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
Regex myreg = new Regex(@"^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"); //email验证
if (myreg.IsMatch(textBox1.Text))
{
email = textBox1.Text;
this.DialogResult = DialogResult.OK;
}
else
{
textBox1.Text = "";
msg.Text = "邮箱格式不正确,请重新输入!";
this.DialogResult = DialogResult.None;
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -