AUTHOR: MOHAMMED ABDEL KHALEQ DWIKAT EMAIL:
[email protected]
TOPIC: VISUAL BASIC II / FORMS DATE: 1/31/2020 PAGE: 3 OF 5
Event COMMENTS
Load When form loaded into memory
Click Any click
MouseClick = MouseDown + MouseUp
MouseDown Mouse is pushed down
MouseUp Mouse is released up
KeyPress = KeyDown + KeyUp
KeyDown Key is pushed down
KeyUp Key is released up
FormClosing Upon closing the form
FormClosed After the form is closed
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
'Write code here'For example to initialize variable values
End Sub
You can ask user if he want to save changes when (before) the form closed
Private Sub Form1_FormClosing(sender As Object, e As
System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosing
'If Data changed then ask user whether to save it or not
End Sub
MMEETTHHOODDSS OOFF AA FFOORRMM
If we want to close any form by code written on the form itself, we
write
Method COMMENTS
close Close the form (remove it from memory) - me.close
, form1.colse
show Show the form - form1.show()
showdialog Show the form as dialog –form1.showDialog()
Hide Me.hide or form1.hide (remains in memory)
Centertoparent Display it centered relative to parent
CenterToScreen Display it centered relative to screen
The .close() method, will close any form and remove it from memory, we
write the form name to be closed as formName.close()
Close form2 (code is written on form2) me.close()
Close form2 (code is written on form1) form2.close()
Open form2 code
What is Dialog mean – it means a form is shown and your action is
required before you can go to previous form or any other form)
Form2.ShowDialog() (you can’t go back to from1 unless you close form2)
Form2.Show()’(you can go back to from1 then again to form2 and so on)
Close form2 when clicking on it