Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Evento KeyDown non funzionante

    Salve, oggi mi sto imbattendo in questo problema.. L' evento KeyDown non funziona. Per testarlo, ho provato con un codice semplice, il codice completo è il seguente.

    codice:
    Public Class Form2
    
        Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.Scroll
            contatore.Text = TrackBar1.Value
            If Timer1.Enabled = True Then
                Timer1.Enabled = False
                Timer1.Interval = TrackBar1.Value * 100
                Timer1.Enabled = True
            Else
                Timer1.Interval = TrackBar1.Value * 100
            End If
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Timer1.Enabled = True
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Timer1.Enabled = False
        End Sub
    
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim totale As Integer = 0
            totale = totale + 1
            totpack.Text = totale
            My.Computer.Keyboard.SendKeys(TextBox1.Text)
            My.Computer.Keyboard.SendKeys("{ENTER}")
        End Sub
    
        Private Sub Form2_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
            MsgBox(e.KeyCode)
        End Sub
    End Class
    E' un codice semplice come si può notare, non capisco perchè premendo un tasto non appaia il suo Code come specificato. (PS: C'è solo Form2 come form, il primo è stato cancellato pensando che si fosse "buggato" con questo problema)
    Social Network in costruzione.. Misto tra Twitter e Facebook.. Twitbook o facetter?

  2. #2
    Utente di HTML.it L'avatar di escocat
    Registrato dal
    Feb 2012
    Messaggi
    308
    La proprietà TabStop di button1 dovrebbe essere messa su false?

  3. #3
    Risolto, bisognava impostare KeyPreview del form a true.
    Social Network in costruzione.. Misto tra Twitter e Facebook.. Twitbook o facetter?

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.