Share via


Changing the behavior of the Help Button

If you're playing around with the Visual Studio 2005 Beta 2, you'll notice the appearance of a help button at the top of the dialogs. Rather than taking up 75x23 pixels of real estate, the dialogs in Visual Studio have chosen to repurpose the "?" button in the title bar.  Instead of going into the "What's this?" contextual help mode, clicking this button for dialogs in VS 2005 should bring up full-fledged help.

If you want to use the same help style in your application set these properties on Form:
MaximizeBox = false;
   MinimizeBox = false;
HelpButton = true;

We can tweak the Everett HelpProvider sample to see how to enable this new "help mode"

At the bottom of the constructor from the above sample add these few lines:

this.helpProvider1.SetShowHelp(this, true); // enable help for the entire dialog
this.HelpButtonClicked += new CancelEventHandler(Form1_HelpButtonClicked);
this.helpLabel.Text = "Using the HelpButtonClicked event, we can directly show help for this dialog when someone presses the ? button";

And this funny handler:

          void Form1_HelpButtonClicked(object sender, CancelEventArgs e) {
e.Cancel = true; // Cancel the "What's this?" mode

            // directly call OnHelpRequested for the form:
OnHelpRequested(new HelpEventArgs(Point.Empty));
}

And for extra fun, you can also now manually show/hide the icon via

   ShowIcon = false;