Difference between ItemGotFocus and ItemGotSelection
|Date:||17 May 2000|
|Abstract:||Difference between ItemGotFocus and ItemGotSelection in Visual LANSA|
|Submitted By:||LANSA Technical Support|
|Last Review:||November 2010|
There is a difference between ItemGotFocus and ItemGotSelection and it only becomes evident in MultiSelect and Extended Selection situations.
When dealing with single selection situations, selection and focus are always the same. The TreeView and ComboBox components only support single selection, so this condition always applies to them.
The ListBox, ListView and Grid components support a selection style property that allows more than just single selection.
When a multi-select situation occurs, multiple items can be selected simply by clicking on the item. Clicking on an already selected item deselects it.
When extended selection applies, items can be selected using Control and Shift key combinations.
In all these situations, focus is always on the item that contains the hatching around the text (referred to as the Focus rectangle).
It is always a good practice to use ItemGotFocus when the application needs to modify other parts of the form based on the focus item - the one that the user last clicked on.
Handling ItemGotSelection events should be used for those applications that do work on one or more selected items where that work does not depend on the focus item - just the selection state.