Tuesday, February 2, 2010

Key Combination Event on Visual Studio – Vb.NET

When you create desktop application, you will need to create a form that handle keypress event, this functional will help you to trace event on your form application, interest for this event …



For Example when you press Ctrl-D button, application will set more width of your form, and this VB.NET code will help you :

The Step to do this :
1. Set form properties – KeyPreview = True

image

2. After that copy this code to your application

Private Sub frmMain_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        ' will expand the form - for expert tools
        If e.Control AndAlso e.KeyCode = Keys.D Then
            Me.Width = 500
        End If
        ' will collapse the form - for standard tools
        If e.Control AndAlso e.KeyCode = Keys.A Then
            Me.Width = 200
        End If
End Sub












No comments:

Hukum Tabur Tuai

Ingatlah hukum dasar ini, dalam kehidupanmu  Barang siapa yang menanam, dia pula yang akan menuai