Results 1 to 2 of 2

Thread: How to identify which textBox has triggered an event?

  1. #1
    Contributing Member
    Join Date
    Jul 2008
    Answers
    35

    Smile How to identify which textBox has triggered an event?

    Hi,

    I have a 2- Dimensional array of textBox generated dynamically in C# Windows Application developed in Visual Studio 2005. I need to do specific tasks when the user hits enter on these text boxes. It should detect and execute the method/subroutine only once (If the user hits enter key on the textbox again then it will not execute the method).

    I need to use only one method for handling the event.

    keypressed(Object o Eventargs e....){

    //Some code as subroutine.
    }

    My code is working fine but itís not able to identify whether itís a first hit seconds hit ....and so on.

    If there any way I can detect as to which textbox has triggered the event. So that I can deactivate the subroutine when the user hits enter on the same textbox again in the key pressed event.

    Thanks,
    J


  2. #2
    Junior Member
    Join Date
    Mar 2009
    Answers
    10

    Re: How to identify which textBox has triggered an event?

    I think the first argument of the event handler is a reference to the object that triggered the event. When the event is triggered you can remove the event from that textbox. Something like ((TextBox)o) -= keydownevent. I hope this provides some ideas. You may also derive your own textbod and add a boolean flag to it to check.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact