ListBox Shortcut tip

Hello good people,

I’m trying to implement some keyboard shortcuts in this Listbox project. I’d like that some columns to be restricted and the user can change the values only by this shortcut.
For example, the first column accepts 3 values, “Value_A”, “Value_B”, “Value_C” and these are alternating by “a”,“b”,“c” keys.

I tried that on CellKeyDown event:

Case Chr(97) // 'a' char Select Case Me.Cell(row,column) Case "", "Value_C" Me.Cell(row,column)="Value_A" Case "Value_A" Me.Cell(row,column)="Value_B" Case "Value_B" Me.Cell(row,column)="Value_C" End Select

But nothing happens with this code, unless I put a breakpoint it, then it works flawlessly. Maybe I’m trying to edit the cell by setting Me.Cell at the same time I press a viable input ‘a’. What am I missing here?

Do you return true ?

I included “Return True”, but with no success yet

What are you trying to obtain ?

Let’s say we have 2 car model names
If I press “a” in this cell, the cell must receive “CarModel1”
If i press “b” in this cell, the cell must receive “CarModel2”

fair enough?

Hierarchical Listbox (LB): a click expand the LB showing what you want…

RadioButtons outside of the LB: a click display the right data in the LB ?

Edit: ends the last sentence.

OK. What is going on is that you are trying to use an event that exists only when a cell is currently being edited. So you need to make the column editable, and the user has to click to put the cell in edition mode.

But then, you cannot fill directly that cell, since it is edited, and in fact, it is the Text property of ActiveCell you need to modify.

Here is a way to obtain what you want :

  • In the Listbox Open event, you want to put :
me.ColumnType(0) = Listbox.TypeEditable

[code]Function CellKeyDown(row as Integer, column as Integer, key as String) Handles CellKeyDown as Boolean

Select Case key
Case Chr(97) // ‘a’ char
Me.ActiveCell.text = “CarModel1”
Return True
Case “b”
Me.ActiveCell.text = “CarModel2”
Return True
End Select
End Function

That is it! much appreciated