none
call private void btnSave_Click(object sender, EventArgs e)

    Question

  • How can I call

    private void btnSave_Click(object sender, EventArgs e)

    from

    private void txtName_KeyDown(object sender, KeyEventArgs e)


    something like:


    private void txtName_KeyDown(object sender, KeyEventArgs e)
    {
     if (e.KeyCode == Keys.Enter)
     {
       RUN btnSave_Click
     }
    }




    Jassim Rahma
    Monday, March 22, 2010 9:57 PM

Answers

  • The .NET coders thought it would be something that users would want:  Button.PerformClick.
    • Marked as answer by Jassim Rahma Tuesday, March 23, 2010 1:58 PM
    Monday, March 22, 2010 10:14 PM

All replies

  • One way to do this is to build a function to perform whatever operation you need.

    Then call that function from btnSave_Click and from TxtName_KeyDown.

    That way you can have the shared code without one event needing to call the other.

    Hope this helps.


    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Proposed as answer by ShinStone Tuesday, March 23, 2010 2:46 AM
    Monday, March 22, 2010 10:03 PM
  • The .NET coders thought it would be something that users would want:  Button.PerformClick.
    • Marked as answer by Jassim Rahma Tuesday, March 23, 2010 1:58 PM
    Monday, March 22, 2010 10:14 PM