Partilhar via


Evento Shape.PreviewKeyDown

Ocorre antes do KeyDown quando uma tecla é pressionada e o foco está na forma de evento.

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (em Microsoft.VisualBasic.PowerPacks.Vs.dll)

Sintaxe

'Declaração
<BrowsableAttribute(True)> _
Public Event PreviewKeyDown As PreviewKeyDownEventHandler
[BrowsableAttribute(true)]
public event PreviewKeyDownEventHandler PreviewKeyDown
[BrowsableAttribute(true)]
public:
 event PreviewKeyDownEventHandler^ PreviewKeyDown {
    void add (PreviewKeyDownEventHandler^ value);
    void remove (PreviewKeyDownEventHandler^ value);
}
[<BrowsableAttribute(true)>]
member PreviewKeyDown : IEvent<PreviewKeyDownEventHandler,
    PreviewKeyDownEventArgs>
JScript não oferece suporte a eventos.

Comentários

O PreviewKeyDown evento permite interceptar teclas e executar ações antes do KeyDown evento ocorre. Todas as chaves tratadas neste evento não serão passadas para o KeyDown eventos.

Para obter mais informações sobre como identificar eventos, consulte Manipulando e acionando eventos.

Exemplos

O exemplo a seguir mostra como responder a PreviewKeyDown evento em um manipulador de eventos. Este exemplo requer que você tenha um OvalShape controle denominado OvalShape1 em um formulário.

Private Sub OvalShape1_PreviewKeyDown(
   ByVal sender As Object, 
   ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs
  ) Handles OvalShape1.PreviewKeyDown

    If e.KeyCode = Keys.F1 Then 
        ' Display a pop-up Help window to assist the user.
        Help.ShowPopup(OvalShape1.Parent, 
          "This shape represents a network node.", 
          PointToScreen(New Point(OvalShape1.Width, 
          OvalShape1.Height)))
    End If 
End Sub
private void ovalShape1_PreviewKeyDown(object sender, 
    System.Windows.Forms.PreviewKeyDownEventArgs e)
{
    if (e.KeyCode == Keys.F1)
    // Display a pop-up Help window to assist the user.
    {
        Help.ShowPopup(ovalShape1.Parent, 
            "This shape represents a network node.", 
            PointToScreen(new Point(ovalShape1.Width, ovalShape1.Height)));
    }
}

Segurança do .NET Framework

Consulte também

Referência

Shape Classe

Namespace Microsoft.VisualBasic.PowerPacks

Outros recursos

Como desenhar linhas com o controle LineShape (Visual Studio)

Como desenhar formas com os controles OvalShape e RectangleShape (Visual Studio)

Introdução aos controles de linha e forma (Visual Studio)