I'm getting into event handling now, and it seems quite confusing to me. See, I come from a web-dev background, so this event stuff is quite new to me.
I'm developing in C# / VS08 and created my Application in the WinForm-Designer.
Now, I created this program overview;
ProgramContext
MainForm : Form
LoginForm : Form
So, what I want to do is when the user clicks "Logout" (What is a menu item in the MainMenu of MainForm), that the application logs out the user.
But how can I access the "Click" event of the logout item from the ProgramContext's view, as there is all the logic of logging in etc.
I tried the following
MenuItem[] findLogout = MainMenuStrip.Items.Find("logoutMenuItem", true); // Throws NullPointerException
findLogout[0].Click += new EventHandler(LogoutClick);
private void LogoutClick(object sender, EventArgs e)
{
// Logout user
}
But keep getting a NullPointerException at the first line.