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. ms access afterupdate event in c# textbox

ms access afterupdate event in c# textbox

Scheduled Pinned Locked Moved C#
csharphelpquestion
3 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.
  • A Offline
    A Offline
    Asif Rehman
    wrote on last edited by
    #1

    I'm unable to get ms access afterupdate event like functionality in c# textbox. What I have done so far is: private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData.Equals(Keys.Enter)) MoveToSpecificVocNo(); } and Leave event private void VocNoTextBox_Leave(object sender, EventArgs e) { MoveToSpecificVocNo(); } But the problem is If I press enter and press tab to move to next field. The event is called twice. One for Enter key, another for Leave. Is there any solution? Regards Asif Rehman

    J 2 Replies Last reply
    0
    • A Asif Rehman

      I'm unable to get ms access afterupdate event like functionality in c# textbox. What I have done so far is: private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData.Equals(Keys.Enter)) MoveToSpecificVocNo(); } and Leave event private void VocNoTextBox_Leave(object sender, EventArgs e) { MoveToSpecificVocNo(); } But the problem is If I press enter and press tab to move to next field. The event is called twice. One for Enter key, another for Leave. Is there any solution? Regards Asif Rehman

      J Offline
      J Offline
      JOAT MON
      wrote on last edited by
      #2

      One way would be using a flag to indicate it had been run already. At the form level:

      private bool func_called = false;

      In KeyDown you set it to true after calling the function:

      private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e)
      {
      if (e.KeyData.Equals(Keys.Enter))
      {
      MoveToSpecificVocNo();
      func_called = true; // <---
      }
      }

      And in Leave you reset it (if this is appropriate for what it does):

      private void VocNoTextBox_Leave(object sender, EventArgs e)
      {
      if ( !func_called )
      {
      MoveToSpecificVocNo();
      }

      func_called = false; //<---
      }

      Jack of all trades ~ Master of none.

      1 Reply Last reply
      0
      • A Asif Rehman

        I'm unable to get ms access afterupdate event like functionality in c# textbox. What I have done so far is: private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyData.Equals(Keys.Enter)) MoveToSpecificVocNo(); } and Leave event private void VocNoTextBox_Leave(object sender, EventArgs e) { MoveToSpecificVocNo(); } But the problem is If I press enter and press tab to move to next field. The event is called twice. One for Enter key, another for Leave. Is there any solution? Regards Asif Rehman

        J Offline
        J Offline
        JOAT MON
        wrote on last edited by
        #3

        Possibly a better way (depends on what MoveToSpecificVocNo() does) is to implement the SendKeys class:

        private void VocNoTextBox_KeyDown(object sender, KeyEventArgs e)
        {
        if (e.KeyData.Equals(Keys.Enter))
        {
        SendKeys.Send ( "\t" );
        }
        }

        This will cause the focus to jump and trigger the Leave event.

        Jack of all trades ~ Master of none.

        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