ToolStripDropDown.ProcessMnemonic(Char) ToolStripDropDown.ProcessMnemonic(Char) ToolStripDropDown.ProcessMnemonic(Char) ToolStripDropDown.ProcessMnemonic(Char) Method

Definición

Procesa un carácter de tecla de acceso.Processes a mnemonic character.

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

Parámetros

charCode
Char Char Char Char

Carácter que se va a procesar.The character to process.

Devoluciones

true si el control procesó el carácter como carácter de tecla de acceso; de lo contrario, false.true if the character was processed as a mnemonic by the control; otherwise, false.

Ejemplos

En el ejemplo de código siguiente se muestra una extensión de la clase Button que reemplaza ProcessMnemonic el método para mostrar el comportamiento personalizado.The following code example demonstrates an extension of the button class that overrides the ProcessMnemonic method to exhibit custom behavior. En el ejemplo también se muestra el uso CanSelect de IsMnemonic las propiedades y.The example also demonstrates the use of the CanSelect and IsMnemonic properties. Para ejecutar este ejemplo, pegue el código siguiente después de una clase de formulario, en el mismo archivo.To run this example, paste the following code after a form class, in the same file. Agregue un botón de tipo MnemonicButton al formulario.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

Comentarios

Se llama a este método para proporcionar a un control la oportunidad de procesar un carácter de tecla de método.This method is called to give a control the opportunity to process a mnemonic character. El método debe determinar si el control se encuentra en un estado para procesar los códigos de tecla y si el carácter especificado representa un mnemotécnico.The method should determine whether the control is in a state to process mnemonics and if whether the given character represents a mnemonic. Si es así, el método debe realizar la acción asociada con el mnemotécnico y truedevolver.If so, the method should perform the action associated with the mnemonic and return true. De lo contrario, el método debe falsedevolver.If not, the method should return false. A menudo, las implementaciones de este IsMnemonic método usan el método para determinar si el carácter especificado coincide con un mnemotécnico en el texto del control.Implementations of this method often use the IsMnemonic method to determine whether the given character matches a mnemonic in the control's text.

Por ejemplo:For example:

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

Esta implementación predeterminada del ProcessMnemonic método simplemente devuelve false para indicar que el control no tiene ningún mnemotécnico.This default implementation of the ProcessMnemonic method simply returns false to indicate that the control has no mnemonic.

Seguridad

UIPermission
para todas las ventanas que heredan clases para llamar a este método.for all windows for inheriting classes to call this method. Enumeración asociada AllWindows : valor UIPermissionWindowde.Associated enumeration: AllWindows value of UIPermissionWindow.

Se aplica a

Consulte también: