Control.ProcessMnemonic(Char) 메서드

정의

니모닉 문자를 처리합니다.Processes a mnemonic character.

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

매개 변수

charCode
Char

처리할 문자입니다.The character to process.

반환

컨트롤이 문자를 니모닉으로 처리하면 true이고, 그렇지 않으면 false입니다.true if the character was processed as a mnemonic by the control; otherwise, false.

예제

다음 코드 예제에서는 ProcessMnemonic 메서드를 재정의 하 여 사용자 지정 동작을 수행 하는 button 클래스의 확장을 보여 줍니다.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. 이 예제를 실행 하려면 동일한 파일의 form 클래스 뒤에 다음 코드를 붙여넣습니다.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.

적용 대상

추가 정보