2012-02-07 10 views
5

पर मदद बटन दबाने मैं जहां मैं एक मदद बटन के साथ Messagebox.Show उपयोग कर रहा हूँ एक सी # अनुप्रयोग है, माइक्रोसॉफ्ट के उदाहरण के अनुसार, लेकिन दबाने सहायता बटन घटना को कभी भी नहीं चलाता - फॉर्म पर F1 दबाकर हालांकि करता है। यहां तक ​​कि माइक्रोसॉफ्ट के उदाहरण को लेकर पूरी तरह से घटना को आग नहीं लगाती है। पूरा कोड नीचे है। कोई विचार जो मैं नहीं कर रहा हूं?घटना पर <a href="http://msdn.microsoft.com/en-us/library/szwxe9we.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/library/szwxe9we.aspx</a></p> <p>मैं फार्म के लिए ईवेंट जोड़ने फायरिंग नहीं जब संदेशबॉक्स

another post है जहां किसी ने इसे देखा था।

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 

namespace WindowsFormsApplication4 
{ 
    public partial class Form1 : Form 
    { 
     public Form1() 
     { 
      InitializeComponent(); 

      DialogResult r = AlertMessageWithCustomHelpWindow(); 
     } 
     // Display a message box with a Help button. Show a custom Help window 
     // by handling the HelpRequested event. 
     private DialogResult AlertMessageWithCustomHelpWindow() 
     { 
      // Handle the HelpRequested event for the following message. 
      this.HelpRequested += new System.Windows.Forms.HelpEventHandler(this.Form1_HelpRequested); 

      this.Tag = "Message with Help button."; 

      // Show a message box with OK and Help buttons. 
      DialogResult r = MessageBox.Show("Message with Help button.", 
               "Help Caption", MessageBoxButtons.OK, 
               MessageBoxIcon.Question, 
               MessageBoxDefaultButton.Button1, 
               0, true); 

      // Remove the HelpRequested event handler to keep the event 
      // from being handled for other message boxes. 
      this.HelpRequested -= new System.Windows.Forms.HelpEventHandler(this.Form1_HelpRequested); 

      // Return the dialog box result. 
      return r; 
     } 

     private void Form1_HelpRequested (System.Object sender, System.Windows.Forms.HelpEventArgs hlpevent) 
     { 
      // Create a custom Help window in response to the HelpRequested event. 
      Form helpForm = new Form(); 

      // Set up the form position, size, and title caption. 
      helpForm.StartPosition = FormStartPosition.Manual; 
      helpForm.Size = new Size(200, 400); 
      helpForm.DesktopLocation = new Point(this.DesktopBounds.X + 
                this.Size.Width, 
                this.DesktopBounds.Top); 
      helpForm.Text = "Help Form"; 

      // Create a label to contain the Help text. 
      Label helpLabel = new Label(); 

      // Add the label to the form and set its text. 
      helpForm.Controls.Add(helpLabel); 
      helpLabel.Dock = DockStyle.Fill; 

      // Use the sender parameter to identify the context of the Help request. 
      // The parameter must be cast to the Control type to get the Tag property. 
      Control senderControl = sender as Control; 

      helpLabel.Text = "Help information shown in response to user action on the '" + 
           (string)senderControl.Tag + "' message."; 

      // Set the Help form to be owned by the main form. This helps 
      // to ensure that the Help form is disposed of. 
      this.AddOwnedForm(helpForm); 

      // Show the custom Help window. 
      helpForm.Show(); 

      // Indicate that the HelpRequested event is handled. 
      hlpevent.Handled = true; 

     } 


    } 
} 
+0

इस प्रश्न पर एक नज़र डालें और देखें कि उत्तर http://stackoverflow.com/questions/2822805/messagebox-show-not-raising-helprequested-event –

उत्तर

4

Form1 निर्माता से बाहर लाइन

DialogResult r = AlertMessageWithCustomHelpWindow(); 

ले लो - हो सकता है मुख्य रूप पर एक बटन क्लिक हैंडलर में डाल दिया। ऐसा लगता है कि आप UIB धागे को संदेशबॉक्स के साथ अवरुद्ध कर रहे हैं। शो() मदद संवाद संवाद को रोकना।

+0

धन्यवाद पॉल - यह किया – user1195062

संबंधित मुद्दे

 संबंधित मुद्दे