C#编程问题,函数重载与委托类型不匹配 30
usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Da...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class MaskTextBoxExample : Form
{
public MaskTextBoxExample()
{
InitializeComponent();
maskedTextBoxBirthday.ValidatingType = typeof(DateTime);
maskedTextBoxPhone.MaskInputRejected += new MaskInputRejectedEventHandler(MyMaskInputRejected);
maskedTextBoxPhone.KeyDown += new KeyEventHandler(MyMaskInputReset);
maskedTextBoxSalary.MaskInputRejected += new MaskInputRejectedEventHandler(MyMaskInputRejected);
maskedTextBoxSalary.KeyDown += new KeyEventHandler(MyMaskInputReset);
}
private void maskedTextBox3_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
{
if(!e.IsValidInput)
{
MessageBox.Show("你输入的日期格式不对");
((MaskedTextBox)sender).Focus();
((MaskedTextBox)sender).InsertKeyMode = InsertKeyMode.Overwrite;
}
}
private void buttonOk_Click(object sender, EventArgs e)
{
if (maskedTextBoxUserCode.Text == " -" || maskedTextBoxUserName.Text == "")
{
MessageBox.Show("您没有填写用户名或真实姓名!");
maskedTextBoxUserCode.Focus();
return;
}
labelResult.Visible = true;
labelResult.Text = string.Format("新添加雇员的信息如下:/n" + "员工号:/n姓名:/n出生日期:/n电话号码:/n月薪:/n",
maskedTextBoxUserCode.Text,
maskedTextBoxUserName.Text,
maskedTextBoxBirthday.Text,
maskedTextBoxPhone.Text,
maskedTextBoxSalary.Text);
}
public void MyMaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
((MaskedTextBox)sender).ForeColor = Color.Red;
}
public void MyMaskInputReset(object sender, MaskInputRejectedEventArgs e)
{
((MaskedTextBox)sender).InsertKeyMode = InsertKeyMode.Overwrite;
((MaskedTextBox)sender).ForeColor = Color.FromName("Windows Text");
}
}
}
调试时候,出现MyMaskInputRefected重载与KeyEventHandler委托类型不匹配。请高手给解答。 展开
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class MaskTextBoxExample : Form
{
public MaskTextBoxExample()
{
InitializeComponent();
maskedTextBoxBirthday.ValidatingType = typeof(DateTime);
maskedTextBoxPhone.MaskInputRejected += new MaskInputRejectedEventHandler(MyMaskInputRejected);
maskedTextBoxPhone.KeyDown += new KeyEventHandler(MyMaskInputReset);
maskedTextBoxSalary.MaskInputRejected += new MaskInputRejectedEventHandler(MyMaskInputRejected);
maskedTextBoxSalary.KeyDown += new KeyEventHandler(MyMaskInputReset);
}
private void maskedTextBox3_TypeValidationCompleted(object sender, TypeValidationEventArgs e)
{
if(!e.IsValidInput)
{
MessageBox.Show("你输入的日期格式不对");
((MaskedTextBox)sender).Focus();
((MaskedTextBox)sender).InsertKeyMode = InsertKeyMode.Overwrite;
}
}
private void buttonOk_Click(object sender, EventArgs e)
{
if (maskedTextBoxUserCode.Text == " -" || maskedTextBoxUserName.Text == "")
{
MessageBox.Show("您没有填写用户名或真实姓名!");
maskedTextBoxUserCode.Focus();
return;
}
labelResult.Visible = true;
labelResult.Text = string.Format("新添加雇员的信息如下:/n" + "员工号:/n姓名:/n出生日期:/n电话号码:/n月薪:/n",
maskedTextBoxUserCode.Text,
maskedTextBoxUserName.Text,
maskedTextBoxBirthday.Text,
maskedTextBoxPhone.Text,
maskedTextBoxSalary.Text);
}
public void MyMaskInputRejected(object sender, MaskInputRejectedEventArgs e)
{
((MaskedTextBox)sender).ForeColor = Color.Red;
}
public void MyMaskInputReset(object sender, MaskInputRejectedEventArgs e)
{
((MaskedTextBox)sender).InsertKeyMode = InsertKeyMode.Overwrite;
((MaskedTextBox)sender).ForeColor = Color.FromName("Windows Text");
}
}
}
调试时候,出现MyMaskInputRefected重载与KeyEventHandler委托类型不匹配。请高手给解答。 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询