Event Sequences in Visual Basic VB6

From Free Knowledge Base- The DUCK Project: information for everyone
Revision as of 07:59, 2 February 2008 by Admin (Talk | contribs)

Jump to: navigation, search
Action Events triggered (in order)
form load Form_Load
Form_Resize
Form_Activate
firsttabindexcontrol_GotFocus
Form_Paint
form minimize Form_Resize
form restore from icon Form_Paint (note: no Form_Resize)
form maximize Form_Resize
Form_MouseMove (note: even with no mouse movement!)
Form_Paint
form restore from max Form_Resize
form move by drag Form_MouseMove...
form resize by drag Form_MouseMove...
Form_Resize
Form_Paint
Form_MouseMove... (note 2nd 'relative' move)
form close Form_QueryUnload
Form_Unload
click in text box Text1_MouseMove... (only when Text1.Enabled is True)
(sets Text1.SelStart BEFORE MouseDown event)
Text1_MouseDown (note: before LostFocus!)
prevcontrol_LostFocus
Text1_GotFocus
Text1_MouseUp
Text1_Click
single character in text box Text1_MouseMove...
Form_KeyDown (if Form.KeyPreview is True)
Text1_KeyDown
Form_KeyPress (if Form.KeyPreview is True)
Text1_KeyPress
Text1_Change
Form_KeyUp (if Form.KeyPreview is True)
Text1_KeyUp
combo box set by listindex Combo1_Click (note: no Change event!)
single character in combo box Combo1_GotFocus
Combo1_KeyDown
Combo1_KeyPress
Combo1_Change
Combo1_KeyUp
combo box select Combo1_DropDown (note: before GotFocus!)
Combo1_GotFocus
Combo1_Click (note: no Change event!)
click on grid cell Grid1_RowColChange (note: before GotFocus!)
Grid1_MouseDown
Grid1_GotFocus
Grid1_SelChange
Grid1_MouseUp
Grid1_Click
click on Command1 while in Text1 Form_MouseMove...
Command1_MouseDown (note: before LostFocus!)
Text1_LostFocus
Command1_GotFocus
Command1_Click (note: before MouseUp!)
Command1_MouseUp
tab from Text1 to Text2 Text1_LostFocus (note: LostFocus before GotFocus)
Text2_GotFocus

 

  • When you click on a control other than the current one, the MouseDown event happens BEFORE the previous control's LostFocus event, and BEFORE the new control's GotFocus event. One valuable use of this is that you can detect the user clicking the Cancel button and programatically avoid running data validation in the LostFocus event of whatever field they were in before clicking Cancel.
  • The Click event for a Command button happens BEFORE the MouseUp event, while for most other controls, it happens AFTER the MouseUp event.
  • A number of controls have events that happen BEFORE the GotFocus event. For example, you can build or adjust the list of a ComboBox in the DropDown event before GotFocus. In the Grid control, you get a RowColChange event before the GotFocus event.
  • When you click in a TextBox, the SelStart property is set (based on the position of the mouse) before ANY other event takes place.