Move selection to next row of a ListBox

I would like move the selection bar to the next row after editing a cell in a ListBox. I cannot figure out what I am doing wrong. I have the following code in the CellAction Event of a List:

//Go to next Row
If Me.ListCount > Me.ListIndex + 1 Then
Me.Selected( Me.ListIndex + 1) = True
End If

//Go to next Row If Me.ListCount > Me.ListIndex + 1 Then Me.ListIndex = Me.ListIndex + 1 End If

?

Thank you Emile, but that did not work. Could this be a bug?

I don’t think so
Maybe you are referring to the wrong event

I also tried CellLostFocus event, and that does not work.

Are you sure there are rows after the one you’re editing?

Yes Greg. I would like to show you an example of my issue. Is there a way to upload a small Xojo project?

If you use a timer with a delay of 50, which call the method after, then works.

Thank you Andreas. So I added a timer to the Window that my ListBox is on, but not sure how to use the timer in my CellAction event procedure.

does this work ?

CellAction:
Sub CellAction(row As Integer, column As Integer)
Timer1.Mode = Timer.ModeSingle
End Sub

TimerAction:
if Listbox1.ListIndex + 1 < Listbox1.ListCount then
Listbox1.ListIndex = Listbox1.ListIndex + 1
'or if you like to edit the cell
’ Listbox1.EditCell(Listbox1.ListIndex + 1,0)
end if

Timer on Window:
Timer Mode: Off
Timer Period: 60 (or more)

Thank you Andreas. That works! Why does it not work without the timer?

http://documentation.xojo.com/index.php/ListBox.ActiveCell

Because the event is called as part of some processing done by the framework. One of the things the framework does after it calls the event is to reset the highlighted line. So you set the highlight to a new line in your code, and then later the framework code sets it back to the old value. Putting your code in a timer causes your code to happen after all the framework code surrounding that event has completed.