Control.ProcessMnemonic(Char) 메서드

정의

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

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

매개 변수

charCode
Char

처리할 문자입니다.

반환

Boolean

컨트롤이 문자를 니모닉으로 처리하면 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 됩니다.

적용 대상

추가 정보