我在EventHandler
为多个按钮工作时遇到了一些困难。他们将执行相同的工作,即链接到相同的表单 ( ModuleTemplate
) 并使用与该模块相关的适当内容填充它。
我只粘贴了有问题的代码。这一切都编译得很好,第一个按钮(btnAudioNotetaker)工作正常,其他按钮什么也不做。
public void createAudioNotetaker()
{
//this button click event works
btnAudioNotetaker.Click += new EventHandler((sender, e) => btnModule_Click(sender, e, audioNotetakerDict, videoPathDict, pdfPathDict, audioPathDict));
}
public void createClaroRead()
{
//this one doesn't work
btnClaroRead.Click += new EventHandler((sender, e) => btnModule_Click(sender, e, audioNotetakerDict, videoPathDict, pdfPathDict, audioPathDict));
}
void btnModule_Click(object sender, EventArgs e, OrderedDictionary pageContent, OrderedDictionary videoPathDict, OrderedDictionary pdfPathDict, OrderedDictionary audioPathDict)
{
//i want to use this event for each button
ModuleTemplate newForm = new ModuleTemplate(pageContent, videoPathDict, pdfPathDict, audioPathDict);
newForm.Show();
this.Hide();
}