我可以有誰建議如何解決這個錯誤?
我收到了此線程的回覆here,但不幸的是沒有作者的回覆。所以我決定在這裏再次發佈他的解決方案。我的用戶控制錯誤
錯誤:錯誤1無法隱式轉換類型 'project1.Utility.AdminController.AdminControllerEvent' 到 'System.EventHandler'
錯誤發生時,我想鉤
//btnDelete.Click += new AdminControllerEvent(btnDelete_Click);
namespace project1.Utility
{
public partial class AdminController : UserControl
{
public delegate void AdminControllerEvent(object sender, AdminControllerEventArgs e);
public event AdminControllerEvent SaveClick;
public event AdminControllerEvent DeleteClick;
public AdminController()
{
InitializeComponent();
//btnDelete.Click += new AdminControllerEvent(btnDelete_Click);
}
private void btnDelete_Click(object sender, AdminControllerEventArgs e)
{
if (DeleteClick != null)
{
if (MessageBox.Show(CoreMessages.DeleteAsk, CoreMessages.DeleteAsk, MessageBoxButtons.OKCancel) == DialogResult.OK)
{
DeleteClick(sender, e);
if (AdminControllerEventArgs.Success)
{
MessageBox.Show(CoreMessages.DeleteSuccess, CoreMessages.Successful, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
MessageBox.Show(CoreMessages.DeleteFailed, CoreMessages.Failed, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
}
}
public class AdminControllerEventArgs : EventArgs
{
public static bool Success;
public AdminControllerEventArgs()
: base()
{
Success = true;
}
}
}
在我的表刪除UI
private void adminController_DeleteClick(object sender, AdminControllerEventArgs e)
{
Repository.Delete(user);
}
是什麼錯誤說? – V4Vendetta 2011-04-22 08:49:48
我添加了錯誤:) – VeecoTech 2011-04-22 08:53:41
點擊已經是一個事件與按鈕有一個不同的簽名比你定義的,所以它將無法映射它 – V4Vendetta 2011-04-22 08:56:06