I’m trying to catch [ENTER] in a Microsoft TreeView-control.
this code runs fine on any ordinary key, but not enter.
Private Sub xProductTreeview_KeyPress(KeyAscii As Integer)
'do something treeview can understand..
Application.Quit
End Sub
now keypress doesn’t trigger on ENTER, so trying KeyDown,
with help from http://www.pcreview.co.uk/forums/here-syntax-treeview-keydown-t3810664.html
the official declaration is incorrect and the following code works:
Private Sub xProductTreeview_KeyDown(KeyCode As Integer, ByVal Shift As Integer)
'do something treeview can understand..
If KeyCode = 32 Then Application.Quit
'Still, KeyCode=13 doesn't trigger nothing..
End Sub
Tried with setting KeyPreivew in access-form to true.
EDIT:
This actually works..
setting KeyPreview to true and:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then MsgBox xProductTreeview.SelectedItem.Text
End Sub
The only thing left so sort out is the returned value is the label-value, which may be non-unique, so how do I get the Key instead of the Text of the node??
regards,
//t
keyPreview=true and