Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 16
  1. #1
    Utente di HTML.it L'avatar di tony83
    Registrato dal
    Feb 2005
    Messaggi
    3,179

    textbox e evento keypress: evitare che l'utenga tenga un tasto sempre premuto

    Come faccio ad evitare che l'utenga tenga un tasto sempre premuto?
    Tony

  2. #2
    Utente di HTML.it L'avatar di Jupy64
    Registrato dal
    Sep 2004
    Messaggi
    1,151
    Ciao, una soluzione veloce:
    codice:
    Dim isKeyPressOk As Boolean = True
    
    Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
        If Not isKeyPressOk Then
            e.SuppressKeyPress = True
        Else
            isKeyPressOk = False
        End If
    End Sub
    Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
        isKeyPressOk = True
    End Sub
    Attenzione, che bisogna prendere in considerazione i tasti ctrl, shift, alt...
    Jupy

  3. #3
    Utente di HTML.it L'avatar di tony83
    Registrato dal
    Feb 2005
    Messaggi
    3,179
    mi dice che e.SuppressKeyPress = True
    non esiste SuppressKeyPress
    ??
    Tony

  4. #4
    Utente di HTML.it L'avatar di tony83
    Registrato dal
    Feb 2005
    Messaggi
    3,179
    up
    Tony

  5. #5
    Utente di HTML.it L'avatar di tony83
    Registrato dal
    Feb 2005
    Messaggi
    3,179
    Qualcuno sa la soluzione?
    Tony

  6. #6
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,472
    Originariamente inviato da tony83
    mi dice che e.SuppressKeyPress = True
    non esiste SuppressKeyPress
    ??
    Purtroppo esiste, quindi probabilmente c'è qualcosa di errato nel tuo codice.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  7. #7
    Utente di HTML.it L'avatar di tony83
    Registrato dal
    Feb 2005
    Messaggi
    3,179
    codice:
        
    Dim isKeyPressOk As Boolean = True
        Dim obj_ClassiPersonali As New classiPersonali.ControlloData.TextBoxData(Me.txt_data, Me.lbl_data, Me.tlt_data, Me.pnl_data)
        Private Sub txt_data_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txt_data.TextChanged
            obj_ClassiPersonali.m_textChange(e, Me.txt_data)
        End Sub
    
        Private Sub txt_data_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt_data.KeyUp
            obj_ClassiPersonali.m_keyUp(e, Me.txt_data)
            isKeyPressOk = True
        End Sub
    
        Private Sub txt_data_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txt_data.KeyDown
            obj_ClassiPersonali.m_keyDown(e, Me.txt_data)
            If Not isKeyPressOk Then
                e.SuppressKeyPress = True   ' mi dà errore qui!
    Else 
                isKeyPressOk = False
            End If
        End Sub
    vb.net 2003 ovviamente

    dice che non è un membro di system.windows.forms.keyeventsargs
    Tony

  8. #8
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,472
    Originariamente inviato da tony83
    vb.net 2003 ovviamente
    dice che non è un membro di system.windows.forms.keyeventsargs
    Ah, ok, allora col 2003 prova ad impostare Handled a True.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

  9. #9
    Utente di HTML.it L'avatar di tony83
    Registrato dal
    Feb 2005
    Messaggi
    3,179
    Originariamente inviato da alka
    Ah, ok, allora col 2003 prova ad impostare Handled a True.
    handled? che proprietà è?

    Non l'Ho trovata..
    Tony

  10. #10
    Moderatore di Programmazione L'avatar di alka
    Registrato dal
    Oct 2001
    residenza
    Reggio Emilia
    Messaggi
    24,472
    Originariamente inviato da tony83
    handled? che proprietà è?
    Non l'Ho trovata..
    E' una proprietà dell'oggetto KeyEventArgs che ti viene passato come parametro.
    MARCO BREVEGLIERI
    Software and Web Developer, Teacher and Consultant

    Home | Blog | Delphi Podcast | Twitch | Altro...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.