ToolStripDropDown.ProcessMnemonic(Char) 메서드

정의

니모닉 문자를 처리합니다.

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

처리할 문자입니다.

반품

true문자가 컨트롤에 의해 니모닉으로 처리되었으면 이고, 그렇지 않으면 . false

예제

다음 코드 예제에서는 사용자 지정 동작을 나타내는 메서드를 재정의 하는 단추 클래스의 ProcessMnemonic 확장을 보여 줍니다. 이 예제에서는 및 속성의 CanSelect 사용도 보여 줍니다 IsMnemonic . 이 예제를 실행하려면 양식 클래스 다음에 다음 코드를 같은 파일에 붙여넣습니다. 폼에 형식 MnemonicButton 의 단추를 추가합니다.

// 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.
    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

설명

이 메서드는 컨트롤에 니모닉 문자를 처리할 수 있는 기회를 제공하기 위해 호출됩니다. 메서드는 컨트롤이 니모닉을 처리하는 상태에 있는지 여부와 지정된 문자가 니모닉을 나타내는지 여부를 결정해야 합니다. 이 경우 메서드는 니모닉과 관련된 작업을 수행하고 반환 true해야 합니다. 그렇지 않은 경우 메서드는 .를 반환 false해야 합니다. 이 메서드의 구현에서는 지정된 문자가 IsMnemonic 컨트롤의 텍스트에서 니모닉과 일치하는지 여부를 확인하는 데 메서드를 사용하는 경우가 많습니다.

다음은 그 예입니다.

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

메서드의 이 기본 구현은 컨트롤에 ProcessMnemonic 니모닉이 없음을 나타내기 위해 반환 false 됩니다.

적용 대상

추가 정보