Reputation: 343
I've recently been messing around with the help button in which you can add to windows form title bar by simply doing the following:
frm.MaximizeBox = false;
frm.MinimizeBox = false;
frm.HelpButton = true;
THE problem is that I'm trying to catch the click event of when this HelpButton is clicked AND then display a MessageBox()
, I've looked into _HelpButtonClicked
but haven't been able to get it working properly (if someone could show a example of that, that would be helpful).
I've tried picking up the click event the same way that you would use when catching the click event of a normal button, but this hasn't worked. Here is a example shown below of what I've tried, the problem is that it DOESN'T work, when HelpButton is pressed the MessageBox()
does NOT pop up:
frm.MaximizeBox = false;
frm.MinimizeBox = false;
frm.HelpButton = true;
frm.HelpButton.Click += HelpButtonClicked;
static void HelpButtonClicked()
{
MessageBox.Show("Help Button Clicked");//Doesn't work :(
}
Any help would be appreciated!
Upvotes: 3
Views: 3584
Reputation: 205619
Your form should handle the HelpButtonClicked event (not a button named HelpButton):
frm.HelpButtonClicked += HelpButtonClicked;
static void HelpButtonClicked(object sender, CancelEventArgs e)
{
MessageBox.Show("Help Button Clicked");//Works :)
}
Upvotes: 6
Reputation: 1164
It looks like you are attempting to use the bool property to wire up the event.
You need to use: Form.HelpButtonClicked
Reference: https://msdn.microsoft.com/en-us/library/system.windows.forms.form.helpbuttonclicked(v=vs.110).aspx
Upvotes: 1