StrataFrame Forum

Navigation using the enter key...

http://forum.strataframe.net/Topic16866.aspx

By StarkMike - 6/5/2008

My users prefer using the enter key instead of the tab key for field navigation on the form... instead of creating KeyUp events for EVERY control does somebody know of a better / easier way?



Thanks
By Greg McGuffey - 6/5/2008

I think this may be what you're after...

http://forum.strataframe.net/FindPost15165.aspx
By StarkMike - 6/6/2008

Hey Greg... Thanks for the post but this is what i was looking for... I dont *quite* understand it but it works! ha ha



Protected Overloads Overrides Function ProcessDialogKey(ByVal keyData As Keys) As Boolean

If keyData = Keys.Enter Then

MyBase.ProcessTabKey(CBool(Keys.Tab))

Return True

End If



Return MyBase.ProcessDialogKey(keyData)



End Function



I included this link in case someone wanted more information that I could provide! :-D





http://www.duncanmackenzie.net/blog/517/default.aspx
By Trent L. Taylor - 6/6/2008

This is basically what Greg suggested but doing it at the form level instead of the field level.  ProcessTabKey just executes the underlying Tab code which generally takes the current control that youa re in and calls the SelectNext() methods.  But at any rate, glad you got it going.
By StarkMike - 6/6/2008

We've noticed that when we add this code to an existing form it will move it to the first place on the tab order then wont move any further. The tab key still functions properly...just not the enter key.



However when we create a new form and add this code and controls to it, it works fine... weird.



Any suggestions?
By Trent L. Taylor - 6/6/2008

This should all be in a base form anyway.  This logic should be trigger by a property that is exposed on a your base form that all of your other forms inherit (i.e. EnterIsSameActionAsTab).  When true, you would then allow the Enter to act as a tab.  I think you are trying to make this too complicated.  I did this in minutes as a quick test and it worked.  Just Override the ProcessCmd method on the base form, if the property mentioned above is True, then handle the Enter.  In the Enter, call another private method in your base form that selects the next control.