ToolStripDropDown.ProcessMnemonic(Char) ToolStripDropDown.ProcessMnemonic(Char) ToolStripDropDown.ProcessMnemonic(Char) ToolStripDropDown.ProcessMnemonic(Char) Method

定義

ニーモニック文字を処理します。Processes a mnemonic character.

protected public:
 override bool ProcessMnemonic(char charCode);
protected internal override bool ProcessMnemonic (char charCode);
override this.ProcessMnemonic : char -> bool
Protected Friend Overrides Function ProcessMnemonic (charCode As Char) As Boolean

パラメーター

charCode
Char Char Char Char

処理対象の文字。The character to process.

戻り値

文字がコントロールによってニーモニックとして処理された場合は true。それ以外の場合は falsetrue if the character was processed as a mnemonic by the control; otherwise, false.

次のコード例は、オーバーライドするボタン クラスの拡張機能を示します、ProcessMnemonicメソッドがカスタム動作。The following code example demonstrates an extension of the button class that overrides the ProcessMnemonic method to exhibit custom behavior. 例では、使用も示しています、CanSelectIsMnemonicプロパティ。The example also demonstrates the use of the CanSelect and IsMnemonic properties. この例を実行するには、同じファイル内のフォーム クラスを使用して、次のコードを貼り付けます。To run this example, paste the following code after a form class, in the same file. 型のボタンを追加するMnemonicButtonをフォームにします。Add a button of type MnemonicButton to the form.

// This button is a simple extension of the button class that overrides
// the ProcessMnemonic method.  If the mnemonic is correctly entered,  
// the message box will appear and the click event will be raised.  
// This method makes sure the control is selectable and the 
// mnemonic is correct before displaying the message box
// and triggering the click event.
public ref class MyMnemonicButton: public Button
{
protected:
   bool ProcessMnemonic( char inputChar )
   {
      if ( CanSelect && IsMnemonic( inputChar, this->Text ) )
      {
         MessageBox::Show( "You've raised the click event "
         "using the mnemonic." );
         this->PerformClick();
         return true;
      }

      return false;
   }

};


// This button is a simple extension of the button class that overrides
// the ProcessMnemonic method.  If the mnemonic is correctly entered,  
// the message box will appear and the click event will be raised.  
public class MyMnemonicButton:Button

	// This method makes sure the control is selectable and the 
	// mneumonic is correct before displaying the message box
	// and triggering the click event.
{
	[UIPermission(
        SecurityAction.Demand, Window = UIPermissionWindow.AllWindows)]
        protected override bool ProcessMnemonic(char inputChar)
	{

		if (CanSelect&&IsMnemonic(inputChar, this.Text))
		{
			MessageBox.Show("You've raised the click event " +
				"using the mnemonic.");
			this.PerformClick();
			return true;
		}
		return false;
	}

}
' This button is a simple extension of the button class that overrides
' the ProcessMnemonic method.  If the mnemonic is correctly entered,  
' the message box will appear and the click event will be raised.  
Public Class MyMnemonicButton
    Inherits Button

    ' This method makes sure the control is selectable and the 
    ' mneumonic is correct before displaying the message box
    ' and triggering the click event.
    <System.Security.Permissions.UIPermission( _
    System.Security.Permissions.SecurityAction.Demand, Window:=UIPermissionWindow.AllWindows)> _
    Protected Overrides Function ProcessMnemonic( _
        ByVal inputChar As Char) As Boolean

        If (CanSelect And IsMnemonic(inputChar, Me.Text)) Then
            MessageBox.Show("You've raised the click event " _
                & "using the mnemonic.")
            Me.PerformClick()
            Return True
        End If
        Return False
    End Function

End Class

注釈

このメソッドは、コントロールのニーモニック文字を処理する機会を与えるために呼び出されます。This method is called to give a control the opportunity to process a mnemonic character. メソッドは、およびコントロールが状態ニーモニックを処理するかどうか、特定の文字がニーモニックを表すかどうかを判断する必要があります。The method should determine whether the control is in a state to process mnemonics and if whether the given character represents a mnemonic. かどうか、メソッドの動作を実行、ニーモニックと戻り値に関連付けられているtrueします。If so, the method should perform the action associated with the mnemonic and return true. 場合は、メソッドが返す、falseします。If not, the method should return false. このメソッドの実装を使用して、多くの場合、IsMnemonicする特定の文字がコントロールのテキストでニーモニックと一致するかどうかを判断するメソッド。Implementations of this method often use the IsMnemonic method to determine whether the given character matches a mnemonic in the control's text.

例えば:For example:

if (CanSelect && IsMnemonic(charCode, MyControl.Text) {  
      // Perform action associated with mnemonic.  
       }  

この既定の実装のProcessMnemonicメソッドは単に返しますfalseコントロールにアクセラレータ キーがないことを表します。This default implementation of the ProcessMnemonic method simply returns false to indicate that the control has no mnemonic.

セキュリティ

UIPermission
このメソッドを呼び出すクラスを継承するすべてのウィンドウ。for all windows for inheriting classes to call this method. 列挙型に関連付けられている: AllWindows UIPermissionWindowします。Associated enumeration: AllWindows value of UIPermissionWindow.

適用対象

こちらもご覧ください