Control.IsMnemonic(Char, String) Control.IsMnemonic(Char, String) Control.IsMnemonic(Char, String) Control.IsMnemonic(Char, String) Method

정의

지정된 문자가 특정 문자열의 컨트롤에 할당된 니모닉 문자인지를 확인합니다.Determines if the specified character is the mnemonic character assigned to the control in the specified string.

public:
 static bool IsMnemonic(char charCode, System::String ^ text);
public static bool IsMnemonic (char charCode, string text);
static member IsMnemonic : char * string -> bool
Public Shared Function IsMnemonic (charCode As Char, text As String) As Boolean

매개 변수

charCode
Char Char Char Char

테스트할 문자입니다.The character to test.

text
String String String String

검색할 문자열입니다.The string to search.

반환

true 문자가 컨트롤에 할당된 니모닉 문자이면 charCode이고, 그렇지 않으면 false입니다.true if the charCode character is the mnemonic character assigned to 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

설명

니모닉 문자는 문자 바로 다음에 "&"의 첫 번째 인스턴스는 String합니다.The mnemonic character is the character immediately following the first instance of "&" in a String.

보안

UIPermission
이 메서드를 호출 하는 클래스 상속을 위한 모든 창입니다.for all windows for inheriting classes to call this method. 연관 된 열거형: AllWindows 의 값 UIPermissionWindow합니다.Associated enumeration: AllWindows value of UIPermissionWindow.

적용 대상

추가 정보