listviewitem lvi_1
long li_rc
// unselect old value
IF ai_oldindex > 0 THEN
li_rc = This.GetItem(ai_oldindex, lvi_1)
lvi_1.HasFocus=FALSE
lvi_1.selected=FALSE
li_rc = This.SetItem(ai_oldindex , lvi_1)
END IF
// select new value
li_rc = This.GetItem(ai_newindex , lvi_1)
lvi_1.HasFocus=TRUE
lvi_1.selected=TRUE
li_rc = This.SetItem(ai_newindex , lvi_1)
this.setfocus()
// simulate up arrow then down arrow to move selected item into visible portion of the control
IF ai_newindex < this.totalitems( ) AND ai_newindex > 1 THEN
// decimal value of the virtural keyboard up arrow (0x26)
keybd_event( 38, 1, 0, 0)
// decimal value of the virtural keyboard down arrow (0x28)
keybd_event(40,1,0,0)
ELSEIF ai_newindex = 1 THEN
// decimal value of the virtural keyboard down arrow (0x28)
keybd_event(40,1,0,0)
// decimal value of the virtural keyboard up arrow (0x26)
keybd_event( 38, 1, 0, 0)
END IF