Comment déniches-tu des choses pareilles, si tu ne connais pas VB.net
Nul besoin de le connaître pour consulter son MSDN !Mouais, en fait il code en .NET en douce sans vouloir l'avouer
C'est une blague hein !
Amitiés.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown If e.KeyValue = 46 Then MsgBox("La touche suppr est pressée") TextBox1.SelectionStart = 32767 End If End Sub
Private Sub tBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tBox.KeyDown If e.KeyValue = 46 Then 'code quelconque e.SuppressKeyPress = True End If End Sub
Private Sub SupprimerLigneActive() Dim Déb As Integer, Fin As Integer, Ins As Integer With tBox Déb 0 : Ins .SelectionStart : If Ins = .TextLength Then Exit Sub Do Fin .Text.IndexOf(vbNewLine, Déb) : If Fin -1 Then Exit Do If Fin >= Ins Then Exit Do Déb = Fin + 2 Loop .SelectionStart = Déb .SelectionLength = Fin - Déb + 2 .SelectedText = "" End With End Sub
Public Class Acceuil Private Sub tBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles tBox.TextChanged Normaliser() End Sub ''' <summary> ''' Fait en sorte que tBox.Text se termine par vbNewLine. ''' </summary> Private Sub Normaliser() Dim n As Integer With tBox n = .Text.Length : If .Text.Substring(n - 2, 2) <> vbNewLine Then .Text &= vbNewLine End With End Sub Private Sub tBox_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles tBox.KeyDown If e.KeyValue = 46 Then SupprimerLigneActive() e.SuppressKeyPress = True End If End Sub ''' <summary> ''' Supprime la ligne contenant le début de la sélection. ''' </summary> Private Sub SupprimerLigneActive() Dim Déb As Integer, Fin As Integer, Ins As Integer With tBox Déb 0 : Ins .SelectionStart : If Ins = .TextLength Then Exit Sub Do Fin .Text.IndexOf(vbNewLine, Déb) : If Fin -1 Then Exit Do If Fin >= Ins Then Exit Do Déb = Fin + 2 Loop .SelectionStart = Déb .SelectionLength = Fin - Déb + 2 .SelectedText = "" End With End Sub End Class