ListBox - Capturing CR/Enter Keys

I have a list box with 4 columns. When the user keys in a value in column 0 & hits the enter/return key I want the focus to move to the next column. This I have achieved by capturing the key strokes in the CellKeyDown event handler so it all works very nicely until I get to the last column & hit the return/enter at which point focus is lost rather than moving to the next row.

So the question is how can I grab the Return/Enter action it & dispose of it before it is handed on ?

The same way youhandled it for the previous columns, excepted you check the column # before doing so. If that value = the number of columns, ypou set the focus to Column(0) of the next Row.

is it clear ?

Handling the key means you should return TRUE in the event, even if you are not doing it now.

When you are in a cell, simply check if it’s the last or not.
If it’s the last cell, simply ignore the enter key and return FALSE, for other cells, advance to next cell and return TRUE.

It the Tab key used to do that ?

And Massimo advice is the right one. You may want to go back to column(0) when you issue a Tab and the selected Cell is Column(3).

You also may use the shift key to move back (Shift-Tab / Shift+Tab).

Is it clear now ?