Advanced PowerBuilder

HomePrevious Lesson: ItemError Event
Next Lesson: DbError Event

ItemFocusChanged Event

This event gets triggered whenever the current field looses the focus, irrespective of whether the data was changed or not. Typical use of this event is to give control to the proper field depending on the value of the current field.

Don't confuse this event with LooseFocus event. LooseFocus event triggers when the DataWindow itself looses the focus. Remember that there may be other controls in a window, and the DataWindow control is one of those. A DataWindow control looses its focus when you click on any other control in the window or press TAB key when the focus is on the last field (whichever field has the highest tab order in the DataWindow control) in the last row (unless you add code in the DataWindow control to add a new row as soon as the tab is pressed in the last field.).

Some functions give different results depending on the event from which you are calling the function. For example, say, the cursor is in the product_no field and you press tab. Now, you expect the cursor to go into product_description field. At this point, if you call GetColumnName() function in the ItemChanged event, you get product_no. If you call, the same function in ItemFocusChanged event, you get product_description.
HomePrevious Lesson: ItemError Event
Next Lesson: DbError Event