Home > Back-end >  Winforms .net framework open message box when help button pressed
Winforms .net framework open message box when help button pressed

Time:03-08

I have a winforms csharp project and I am trying to open a message box(or something that I can put text into) when the help button in the control box is pressed. This is the help button I want pressed.

Any help would be great! :)

CodePudding user response:

You need to wire up the HelpRequested or HelpButtonClicked events

Plus you need to get the button shown (off by default on a form) by setting

  • HelpButton = true
  • MinimizeBox = false
  • MaximizeBox = false

CodePudding user response:

Sounds like you're new to C# so I'll give you the most simple rundown I can with examples:

In the InitializeComponent() function you need to add:

HelpRequested  = new System.Windows.Forms.HelpEventHandler(this.form_helpRequested);

This will tell the form to run form_helpRequested once the help button is pressed. Then you can implement this event handler function with:

private void textBox_HelpRequested(object sender, System.Windows.Forms.HelpEventArgs hlpevent)
{
    // Your code here
    // Example of a popup with text:
    MessageBox.Show("This is a help popup");
}

This all needs to be in your Form1.cs (or equivilent) script.

For reference on this event handler, I'd suggest giving this article a read: https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.control.helprequested?view=windowsdesktop-6.0

  • Related