내가 다음 코드방법 이름은/과부하가
newEnterPass pass = new newEnterPass();
private void truncateEmp_Click(object sender, EventArgs e) //TRUNCATE EMPLOYEES
{
if (pass.ShowDialog(this) == DialogResult.OK)
{
pass.proceed.Click += new EventHandler<newEnterPass>(pass.truncateEmp(sender,e));
}
}
그것은 나에게 오류 Method name expected
을 제공하여이 버튼이 위임과 일치하지 않습니다. 내가 다음 코드 (sender, e)
을 제거하면 그것은 나에게 또 다른 오류가 여기에
No overload for 'truncateEmp' matches delegate System.EventHandler<cms.newEnterPass>'
클래스 newEnterPass
public void truncateEmp(object sender, EventArgs e)
{
string pass = passField.Text;
if (pass == "")
{
MessageBox.Show("Did you input something? I doubt it.");
return;
}
bool r = validate_login(pass);
if (r)
{
db_connection();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "TRUNCATE TABLE Employees";
cmd.Connection = connect;
cmd.ExecuteNonQuery();
MessageBox.Show("Success!", "TRUNCATE", MessageBoxButtons.OK, MessageBoxIcon.Information);
logs.LogThatShit_TruncateEmp();
this.Close();
passField.Clear();
connect.Close();
}
else
{
MessageBox.Show("Wrong password!", "TRUNCATE", MessageBoxButtons.OK, MessageBoxIcon.Error);
passField.Clear();
}
}
에서 truncateEmp
의 코드를 누군가가 도와 드릴 것을 줄 것이다? 모두 감사합니다!
대리자를 구성 할 때 매개 변수를 메서드에 전달할 수 없습니다. 대신'new EventHandler (pass.truncateEmp)'를 시도하십시오. –
왜'newEnterPass' 클래스 이름을'EventHandler'의 제네릭 매개 변수로 넣었습니까? –
왜''가 필요한가요? 그냥 + + 새로운 EventHandler (pass.truncateEmp); ' –
praty