Skip to main content

I need to trap the Event, when a Textfield is left. I.e. when I push a defined (e.g. List-) button, the field that had Focus causes a "Leave" Event occuring before the button pressed Event is detected.

I need to suppress any Action on Leave, when not caused by Key Input (Tab or Return). Thanks in advance for any help.

Regards

Rainer

I need to trap the Event, when a Textfield is left. I.e. when I push a defined (e.g. List-) button, the field that had Focus causes a "Leave" Event occuring before the button pressed Event is detected.

I need to suppress any Action on Leave, when not caused by Key Input (Tab or Return). Thanks in advance for any help.

Regards

Rainer

If I am understanding your request correctly you can check in the Leave event to see if the button has the new focus and then ignore the leave event accordingly.

What is it that you are doing in the Leave event?

If you are validating the entry it may be better to use the Validating event instead.

Anyway, somthing like the following:

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
          set textBox2::Text to "click"
       end method.

       method-id textBox1_Leave final private.
       procedure division using by value sender as object e as type System.EventArgs.
          
          if button1::Focused not = true
             *> process your leave action
             set textBox2::Text to "leave"
          end-if
       end method.

I need to trap the Event, when a Textfield is left. I.e. when I push a defined (e.g. List-) button, the field that had Focus causes a "Leave" Event occuring before the button pressed Event is detected.

I need to suppress any Action on Leave, when not caused by Key Input (Tab or Return). Thanks in advance for any help.

Regards

Rainer

No Chris, I can check the Leave Event which, when the field looses Focus calls a method "EvaluateInput". This I need to suppress when no key is pressed. Leave or Validating don't detect another object like a button having been pressed because they occur first.

I can trap Key Events like Function or Enter key through System.Windows.Forms.KeyEventArgs, but, not the Tab Key. Latter would allow me to evaluate a KeyPressed Event rather than Leave to do something.


I need to trap the Event, when a Textfield is left. I.e. when I push a defined (e.g. List-) button, the field that had Focus causes a "Leave" Event occuring before the button pressed Event is detected.

I need to suppress any Action on Leave, when not caused by Key Input (Tab or Return). Thanks in advance for any help.

Regards

Rainer

Sorry Chris, I made a mistake: The Validating Event is the right way. But, I'd appreciate if could tell me how to trap the Tab Key.

Regards

Rainer


I need to trap the Event, when a Textfield is left. I.e. when I push a defined (e.g. List-) button, the field that had Focus causes a "Leave" Event occuring before the button pressed Event is detected.

I need to suppress any Action on Leave, when not caused by Key Input (Tab or Return). Thanks in advance for any help.

Regards

Rainer

If you place your code in the textbox validating event and then set the CausesValidation property of the button to false then the validating event for the textbox should not even be fired when the button is clicked.

If you do need to check for the tab key it is available in the KeyData property:

You can check for the tab key pressed in KeyData as follows:

method-id Form1_PreviewKeyDown final private.

      procedure division using by value sender as object e as type System.Windows.Forms.PreviewKeyDownEventArgs.

          if e::KeyData = type Keys::Tab

             set tabwaspressed to true

          else

             set tabwaspressed to false

          end-if

end method.