I'm trying to pass a program name from my form to a button click event. But I keep getting the following error message:
"No overload for “method” matches delegate 'EventHandler' "
I've read up on similar problems here and tried numerous suggestions but nothing seems to fix my specific problem. I'm hoping someone can tell me where I'm going wrong. Here are some of the posts I've read:
No overload for 'method' matches delegate 'System.EventHandler'
C# CS0123: No overload for matches delegate Eventhandler
Error - No overload for "method" matches delegate 'System.EventHandler'?
I don't seem to have a clear understanding of how to match up the signatures of my event methods. The documentation I've read hasn't helped. Any assistance from a knowledgeable person would be greatly appreciated.
My code is as follows:
using System;
using System.Windows.Forms;
namespace ProgramOne
{
public partial class frmLogin : Form
{
public frmLogin(string pgmName)
{
InitializeComponent();
Click += (sender, EventArgs) => { BtnSubmit_Click(sender, EventArgs, pgmName); };
}
private void BtnSubmit_Click(object sender, EventArgs e, string pgmName)
{
txtUserId.Text = txtUserId.Text.Trim();
txtPassword.Text = txtPassword.Text.Trim();
if (txtUserId.Text == "" || txtPassword.Text == "")
{
MessageBox.Show("Please provide a valid UserID and Password");
return;
}
bool securityCheckPassed = true;
if (securityCheckPassed)
{
//Open new form
MessageBox.Show(frmLogin.pgmName);
}
}
}
}