Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Event order sequence...

Event order sequence...

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    e laj
    wrote on last edited by
    #1

    Hi every body , (sorry for my english...) Suppose we have a text box (textBox1). If we "leave" this text box by pressing the TAB key, the order of the following events is: textBox1_Validated textBox1_LostFocus But, if we leave this text box using the mouse, that is by pressing on another control on the Form using the mouse, the order of these events is: textBox1_LostFocus textBox1_Validated This is strange behavior in my opinion. May anyone explain me this behavior? Thanks in advanced, elaj

    Mircea PuiuM 1 Reply Last reply
    0
    • E e laj

      Hi every body , (sorry for my english...) Suppose we have a text box (textBox1). If we "leave" this text box by pressing the TAB key, the order of the following events is: textBox1_Validated textBox1_LostFocus But, if we leave this text box using the mouse, that is by pressing on another control on the Form using the mouse, the order of these events is: textBox1_LostFocus textBox1_Validated This is strange behavior in my opinion. May anyone explain me this behavior? Thanks in advanced, elaj

      Mircea PuiuM Offline
      Mircea PuiuM Offline
      Mircea Puiu
      wrote on last edited by
      #2

      When you change the focus by using the keyboard, focus events occur in the following order:

      • Enter
      • GotFocus
      • Leave
      • Validating
      • Validated
      • LostFocus

      When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:

      • Enter
      • GotFocus
      • LostFocus
      • Leave
      • Validating
      • Validated

      There is nothing strange in that, is it? -- modified at 5:22 Monday 22nd January, 2007

      SkyWalker

      E 1 Reply Last reply
      0
      • Mircea PuiuM Mircea Puiu

        When you change the focus by using the keyboard, focus events occur in the following order:

        • Enter
        • GotFocus
        • Leave
        • Validating
        • Validated
        • LostFocus

        When you change the focus by using the mouse or by calling the Focus method, focus events occur in the following order:

        • Enter
        • GotFocus
        • LostFocus
        • Leave
        • Validating
        • Validated

        There is nothing strange in that, is it? -- modified at 5:22 Monday 22nd January, 2007

        SkyWalker

        E Offline
        E Offline
        e laj
        wrote on last edited by
        #3

        Hi SkyWalker, There is nothing strange if your code does not depend on it. However, i wrote a code that that register to control's "LostFocus" event and do some job there. If the user call some other method - i unregister the event handler, but it should be done only after the "LostFocus" occurred. Because the the user traditionally will call my method in the "Validate" event, you may understand why this behavior raise some problems. However to overcome it i do the following: I registered to the "GotFocus" event, and within this event handler i registered to the "LostFocus" event. When the "LostFocus" event occurred, i do my job and unregistered the handler when it completed. Elaj

        Mircea PuiuM 1 Reply Last reply
        0
        • E e laj

          Hi SkyWalker, There is nothing strange if your code does not depend on it. However, i wrote a code that that register to control's "LostFocus" event and do some job there. If the user call some other method - i unregister the event handler, but it should be done only after the "LostFocus" occurred. Because the the user traditionally will call my method in the "Validate" event, you may understand why this behavior raise some problems. However to overcome it i do the following: I registered to the "GotFocus" event, and within this event handler i registered to the "LostFocus" event. When the "LostFocus" event occurred, i do my job and unregistered the handler when it completed. Elaj

          Mircea PuiuM Offline
          Mircea PuiuM Offline
          Mircea Puiu
          wrote on last edited by
          #4

          ok :-)

          SkyWalker

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups