skip to Main Content

Happens that I’m generating by mistake some handler code (eg by double/clicking some control)
eg:

     private void btLinks_Click (object sender, EventArgs e) {
          // ....
      } 

Other time Im just deleting method body and want to remove it’s reference in designer
Is there any way in VS to quickly remove this hander?

Currently im doing this that way:

  • shift + F12 -> dind reference
  • go to *.designer file
  • remove line (Ctrl+L)
  • return to class code and remove method

I’d love to find easier and faster way to archive the same.
I wonder how you are doing this guys?
(Cant be just only me dealing with this… 🙂 )

3

Answers


  1. If you just made the handler as your last action (accidental double click) then you can Ctrl+Z and confirm ‘Yes’ to the Loss of Work warning. It will remove both the handler and the designer code.

    If you delete the event in the designer (right click the event in the properties > reset, or delete text), the handler will be removed iff there is no code in that handler.

    Login or Signup to reply.
  2. you can remove event handler by selecting button (or any other control), properties windows, clic event icon, and erasing text beside event :

    enter image description here

    Login or Signup to reply.
  3. Go to the control properties, events and find the corresponding event. Delete it in the properties window.

    1. This will remove the event handler from control
    2. If the handler method has custom code, the method will remain
    3. If the handler method has no code, it will be removed

    Image is to reference the window. But instead of adding, you will be removing the value in the event box

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search