Skip to main content

[Migrated content. Thread originally posted on 18 October 2005]

Having programmatically found a tree item we want to scroll the tree up a few lines and place the focus on the found item. Using the following code:

01 ITEM-1 USAGE POINTER.
01 ITEM-2 USAGE POINTER.

SCR-OETREE-LINE-NO-Ef-Aft-Procedure.
1. PERFORM FIND-ENTERED-LINE.
2. MODIFY SCR-OETREE-TR VALUE ITEM-2.
PERFORM 4 TIMES
3. MODIFY SCR-OETREE-TR NEXT-ITEM = TVNI-NEXT
GIVING ITEM-1
4. MODIFY SCR-OETREE-TR VALUE ITEM-1
END-PERFORM.
5. MODIFY SCR-OETREE-TR VALUE ITEM-2.

The routine at line 1 returns the correct value for item-2 and the item shows as selected after line 2. However, line 3 does not return a value for item-1 even though there are many more items in the tree and since item-1 is 0 line 4 has no effect. Line 5 does return the focus to the correct item. Also we would like lines 2 and 5 to highlight the item as if it was selected with the mouse or arrow key. At present the selection shows gray background when done programmatically and bright blue when selected with mouse or arrow key.



Any suggestions?

[Migrated content. Thread originally posted on 18 October 2005]

Having programmatically found a tree item we want to scroll the tree up a few lines and place the focus on the found item. Using the following code:

01 ITEM-1 USAGE POINTER.
01 ITEM-2 USAGE POINTER.

SCR-OETREE-LINE-NO-Ef-Aft-Procedure.
1. PERFORM FIND-ENTERED-LINE.
2. MODIFY SCR-OETREE-TR VALUE ITEM-2.
PERFORM 4 TIMES
3. MODIFY SCR-OETREE-TR NEXT-ITEM = TVNI-NEXT
GIVING ITEM-1
4. MODIFY SCR-OETREE-TR VALUE ITEM-1
END-PERFORM.
5. MODIFY SCR-OETREE-TR VALUE ITEM-2.

The routine at line 1 returns the correct value for item-2 and the item shows as selected after line 2. However, line 3 does not return a value for item-1 even though there are many more items in the tree and since item-1 is 0 line 4 has no effect. Line 5 does return the focus to the correct item. Also we would like lines 2 and 5 to highlight the item as if it was selected with the mouse or arrow key. At present the selection shows gray background when done programmatically and bright blue when selected with mouse or arrow key.



Any suggestions?
It sounds to me that there is a focus issue. You are programmatically changing the selected item, however, the treeview do not have focus, hence the grey instead of the blue.

[Migrated content. Thread originally posted on 18 October 2005]

Having programmatically found a tree item we want to scroll the tree up a few lines and place the focus on the found item. Using the following code:

01 ITEM-1 USAGE POINTER.
01 ITEM-2 USAGE POINTER.

SCR-OETREE-LINE-NO-Ef-Aft-Procedure.
1. PERFORM FIND-ENTERED-LINE.
2. MODIFY SCR-OETREE-TR VALUE ITEM-2.
PERFORM 4 TIMES
3. MODIFY SCR-OETREE-TR NEXT-ITEM = TVNI-NEXT
GIVING ITEM-1
4. MODIFY SCR-OETREE-TR VALUE ITEM-1
END-PERFORM.
5. MODIFY SCR-OETREE-TR VALUE ITEM-2.

The routine at line 1 returns the correct value for item-2 and the item shows as selected after line 2. However, line 3 does not return a value for item-1 even though there are many more items in the tree and since item-1 is 0 line 4 has no effect. Line 5 does return the focus to the correct item. Also we would like lines 2 and 5 to highlight the item as if it was selected with the mouse or arrow key. At present the selection shows gray background when done programmatically and bright blue when selected with mouse or arrow key.



Any suggestions?
Thank you Gisle! Right on the money as usual.

Vins Nash