Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
help me i want to make a project in which after pressing enter anywhere in a form some other form will get load automatically
example after pressing enter in form1 form2 will get load
Posted

VB
Private Sub Form1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress

    If Keys.Enter Then

        Me.Focus()
        Form2.Show()

    End If

End Sub
 
Share this answer
 
VB
private sub form1_keyup()

If e.KeyCode = Keys.Return Then
            Dim form As New Form
            form.Text = "Form2"
            form.Show()
        End If
 
Share this answer
 
Comments
André Kraak 26-Feb-12 13:57pm    
Edited solution:
Added pre tags
"Treat my content as plain text..." option disabled.
Hi,
Use this code

VB
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles Button1.Click
Dim form2 As New Form2
form2.Show()

End Sub 
 
Share this answer
 
v2
You can use KeyPress , Keydown , or KeyUpevent and check keycode of enter key
do something
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900