DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Accept Enter Key in an user control textbox

  1. #1
    Prasant Guest

    Accept Enter Key in an user control textbox


    Hi,
    I made one user control text box. now i would like to accept the enter key
    in that user control and move the focus to the next text box. Is there any
    way to get the keypress event for the user control. Please help.
    Regards
    Prasant

  2. #2
    Patrick Marshall Guest

    Re: Accept Enter Key in an user control textbox


    Hi Prasant,

    You can do it at the form level for all textboxes on a single form. Set
    the form .keypreview property to "true". On the form_keypress event add:

    'be sure that there is no default button set on the form or it will "eat"
    any vbcrlf's before the form keypreview can process it. The .default property
    is a property of a command button. Only one command button can be default.

    dim cc as control

    set cc = me.activecontrol
    if cc is nothing then exit sub 'no control is active
    if typeof cc is textbox then
    if keyascii = vbkeyreturn then
    keyascii = 0 'suppress keypress to prevent beep
    sendkeys "{TAB}", true 'send tab key, wait for op to complete
    end if
    end if

    <Patrick>

    "Prasant" <prasantkm@hotmail.com> wrote:
    >
    >Hi,
    >I made one user control text box. now i would like to accept the enter key
    >in that user control and move the focus to the next text box. Is there any
    >way to get the keypress event for the user control. Please help.
    >Regards
    >Prasant



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center