Control.ProcessMnemonic(Char) Control.ProcessMnemonic(Char) Control.ProcessMnemonic(Char) Control.ProcessMnemonic(Char) Method

정의

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

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

매개 변수

charCode
Char Char Char Char

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

반환

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

예제

다음 코드 예제에서는 재정의 하는 button 클래스의 확장을 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. 실행 하려면이 예제에서는 후 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.

적용 대상

추가 정보