cs_casy
Messages postés7741Date d'inscriptionmercredi 1 septembre 2004StatutMembreDernière intervention24 septembre 201440 15 janv. 2005 à 20:56
Tiens exemple trouver dans le MSDN qui doit répondre à ton problème
L'exemple
suivant crée un contrôle TextBox. La méthode keypressed utilise la
propriété KeyChar pour vérifier si l'utilisateur a appuyé sur la touche
ENTRÉE. Si c'est le cas, la propriété Handled a la valeur true,
laquelle indique que l'événement est géré.
[Visual Basic]
Imports System
Imports System.Windows.Forms
Public Class Form1
Inherits Form
Public Sub New()
' Create a TextBox control.
Dim tb As New TextBox()
Me.Controls.Add(tb)
AddHandler tb.KeyPress, AddressOf keypressed
End Sub 'New
Sub keypressed(ByVal o As [Object], ByVal e As KeyPressEventArgs)
' The keypressed method uses the KeyChar property to check
' whether the ENTER key is pressed.
' If the ENTER key is pressed, the Handled property is set to true,
' to indicate the event is handled.
If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then