CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2002
    Location
    Bhopal (India)
    Posts
    48

    Question Handle textbox's event by the form

    Hi,
    I have a problem with event handling.

    I have a Form and one textbox drawn on the form. I want to handle the keypress event of textbox as follows:

    whenever I press normal keys like a-z or 0-9 then event occurred on textbox, if I press other than these keys event should be passed to the form.

    I hope Ihave explained my problem.

    If any soln. plz help me.

    Thanks in advance.
    Fazal Khan

    My WebLog

  2. #2
    Join Date
    Aug 2000
    Location
    Essex, Uk
    Posts
    1,214

    Re: Handle textbox's event by the form

    textbox_keypress....

    if (keyascii is within your range) then
    .........
    else
    form_keypress (or which ever event you want to run)

    end if
    If you find my answers helpful, dont forget to rate me

  3. #3
    Join Date
    Sep 2002
    Location
    Bhopal (India)
    Posts
    48

    Re: Handle textbox's event by the form

    Hi,

    Above code may work properly but on every text box i will have to write this code.

    Actually my need is diffrent.

    I want to make our own shorcut keys like Alt+A. If focus is on text box then every event occured on text box. I want to capture all the keys event other than A-Z n 0-9. if user press any key, other than these key. then Form's event should be occured.

    thats it.
    Fazal Khan

    My WebLog

  4. #4
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: Handle textbox's event by the form

    Set the KeyPreview property of the form to True and create an event handler for both the form and the TextBox. Then you just test for the specific keys that you want each to handle. Note that the form will receive the event first.

  5. #5
    Join Date
    Sep 2002
    Location
    Bhopal (India)
    Posts
    48

    Re: Handle textbox's event by the form

    I will see it. if success then thanks.
    Fazal Khan

    My WebLog

  6. #6
    Join Date
    Sep 2002
    Location
    Bhopal (India)
    Posts
    48

    Re: Handle textbox's event by the form

    It's work, Thanks a lot.
    Fazal Khan

    My WebLog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured