If a text box control is in focus the default functionality of Key.Up and Key.Down are to move the cursor right and left respectively within the text box. I am interested in overriding this functionality. In my application a text box is used for inputs which I would like to remember. I would like for the user to be able to press up or down to populate the text box with their last input (or next input if they had gone back already).

To do this I have tried subscribing to the KeyPress event and checking the event arguments for Key.Up and Key.Down. However, this event never seems to get triggered when I use these keys. My thought is that it's being handled somewhere else, perhaps on a form level.

If anybody could point me in the right direction I would be very grateful.

Thanks in advance. :)

try the keydown you have far more control then

try the keydown you have far more control then

Indeed, when I use KeyDown it allows me to hook into when the user presses Up or Down, but the default functionality (cursor moving) is still there. How can I suppress that functionality?

Ah.. Take a look at the other options under keydown.. theres one just what you're looking for

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.