Listbox Move to columns with Shift + Tab

Hi everyone.
I have created an application with listbox (i use it for items ordering).
I use the first column for numbering and move from cell to cell with tab key.
I use delete key to delete a row and cursor moves to the last column of the previous row (as i have planned).
When i press Shift + Tab i move to previous column and if cursor is already in the second column it moves to the previous line last column (as i have planned)
The problem is the first row (0) and second column as it does not move to TextField as planned.
I hereby attach the code for your reference.
Any help is welcomed.!!!

var grammi as Integer
var i as integer
var h as integer

grammi = lista.SelectedRowIndex
i = lista.LastColumnIndex

// Ελεγχος για το κουμπι Shift + ΤΑΒ
if key = chr(9) and keyboard.Shiftkey and i <1 and grammi =0 then
  TextField8.SetFocus
End if
if key = chr(9) and keyboard.Shiftkey and  column >1  then 
  me.EditCellAt(grammi, column -1)
end if
if key = chr(9) and keyboard.Shiftkey and  column =1 and grammi >0 then 
  me.EditCellAt(grammi -1, 5)
end if


// Ελεγχος για το κουμπι ΤΑΒ
if key = chr (9) and not keyboard.Shiftkey and column < 5 then 
  me.EditCellAt(grammi, column +1) 
end if
if key = chr (9) and not keyboard.Shiftkey and column = 5 and me.SelectedRowIndex<>me.LastRowIndex then
  lista.EditCellAt(grammi +1, 1)  
end if
if key = chr (9) and not keyboard.Shiftkey and column = 5 and me.SelectedRowIndex=me.LastRowIndex then 
  seira
  lista.EditCellAt(grammi +1, 1)
end if
TextField11.Text = column.ToText





// ΕΛΕΓΧΟΣ ΑΝ ΠΑΤΗΘΗΚΕ ΤΟ KEY UP
if key = chr(30) and row = 0 and column = 1 then
  TextField8.SetFocus
elseif key = chr(30) and column > 1 then
  me.EditCellAt(row, column -1)
End if

// ΕΛΕΓΧΟΣ ΑΝ ΠΑΤΗΘΗΚΕ ΤΟ ENTER
if key = chr (13) and column < 5 then
  me.EditCellAt(row, column +1)
End if





//ΕΛΕΓΧΟΣ ΑΝ ΠΑΤΗΘΗΚΕ ΤΟ DELETE
if key = chr(127) and me.SelectedRowIndex = 0 and me.RowCount = 1 then 
  me.RemoveRowAt(grammi)
  TextField8.SetFocus
 end if

if key = chr(127) and me.SelectedRowIndex = 0 and me.RowCount > 1 then 
  me.RemoveRowAt(grammi)
  for i=0 to me.RowCount -1
    h = i +1
    lista.CellTextAt(i, 0) = h.ToText
  next
  me.EditCellAt(row, 5)
end if


if key = chr(127) and me.SelectedRowIndex > 0 then 
  me.RemoveRowAt(grammi)
  for i=0 to me.RowCount -1
    h = i +1
    lista.CellTextAt(i, 0) = h.ToText
  next
  me.EditCellAt(row -1, 5)
End If



TextField12.Text = row.ToText
TextField11.Text = column.ToText

i attach the file so someone may test the listbox and see what is happening

If you want to post code, please:

  1. add it to your post
  2. Select it with the mouse
  3. Press the </> button.

Thanks.

1 Like

Continuing the discussion from Listbox Move to columns with Shift + Tab:

i attach the code for understanding how it works

Thank you Tim for the advise.
Lets keep the forum simple and easy reading.

Be well.!!

1 Like

Add Return True after all TextField1.SetFocus in CellKeyDown as you’re moving off the listbox and don’t want it to interfere with the move.

Also doing it in KeyDown will stop the beep.

2 Likes

Thank you
i did inserted Return True and solved beep problem
but actually my interest was in line 0 column 1 as Shift+Tab did not respond as planned (move to previous TextField).
The problem was here:

*********Wrong  Code*********
if key = chr(9) and keyboard.Shiftkey and i <1 and grammi =0 then
  TextField8.SetFocus
End if
*******************************

***************Correct Code***************
if key = chr(9) and keyboard.Shiftkey and column =1 and me.selectedRowIndex =0 then
  TextField8.SetFocus
End if
*********************************

Many thanks for the help
Best Regards

Nektarios