Error 2 Cannot assign to 'methodinForm' because it is a 'method group' G:\Dotnet11\Project\TryDelegateMain\TryDelegateMain\Form1.cs 38 13 TryDelegateMain
namespace TryDelegateMain { public partial class Form1 : Form { public event NewStaffCreatedHandler NewStaffCreated; public delegate void NewStaffCreatedHandler(Form2 NewStaffMember); public Form1() { InitializeComponent(); } protected void CreateNewStaffMember() { Form2 _newStaffMember = new Form2(); //... Code to create the new StaffMember... //Raise the event NewStaffCreated(_newStaffMember); } //This is the method that the delegate points to void NewStaffForm_NewStaffCreated(Form2 NewStaffMember) { //RefreshStaffList(); //NewStaffMember.AddedToList = true; //Do something with the StaffMember object that was passed with the delegate //Create an instance of the NewStaffForm and assign a method to the NewStaffCreatedHandler Form2 _nuForm = new Form2(); _nuForm.methodinForm += new NewStaffCreatedHandler(NewStaffForm_NewStaffCreated); _nuForm.Show(); } } }
namespace TryDelegateMain { public partial class Form2 : Form { public event NewStaffCreatedHandler NewStaffCreated; public delegate void NewStaffCreatedHandler(Form2 NewStaffMember); public Form2() { InitializeComponent(); } public void methodinForm() { //do something } } }
methodinForm
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)