procedure calls

  • Thread starter Thread starter sandy
  • Start date Start date
S

sandy

7. Form1 has three buttons cmdOK, cmdCancel, and cmdTest.
The form needs to have the following characteristics:

When the form is displayed it has to be centered in the
middle of the screen.
When the user presses the 'Enter' key the code for the
event procedure cmdOK_Click needs to be executed.
When the user presses the 'Esc' (escape) key, the code
for the event procedure cmdCancel_Click needs to be
executed.



How would i implement this behavior:
 
Hi Sandra,

A little sample, I think with this you can do the rest yourself.
\\\\\\
Private Sub Form1_KeyDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs) _
Handles MyBase.KeyDown
If e.KeyCode = Keys.Enter Then
Button1_Click(e, Nothing)
End If
End Sub
Private Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Me.Label1.Text = "It's me who did it"
End Sub
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim myScreen As Windows.Forms.Screen _
= Windows.Forms.Screen.PrimaryScreen
Me.Left = myScreen.WorkingArea.Width / 2 _
- Me.Width / 2
End Sub
/////
I hope this helps a little bit?
Cor
 
sandy said:

Where is 1. - 6.?? ;-)
Form1 has three buttons cmdOK, cmdCancel, and cmdTest.
The form needs to have the following characteristics:

When the form is displayed it has to be centered in the
middle of the screen.

Startposition = CenterScreen
When the user presses the 'Enter' key the code for the
event procedure cmdOK_Click needs to be executed.

DefaultButton = cmdOk

When the user presses the 'Esc' (escape) key, the code
for the event procedure cmdCancel_Click needs to be
executed.

CancelButton = cmdCancel
 
Check out the AcceptButton and CancelButton properties of the Form. This is
what you are really looking for.
 
Back
Top