Sophie_R
Sophie_R

Reputation: 41

Windows forms: Finding code that belongs to a button

i have a very simple question but i just can't find the answer. I have an existing Windows forms project which shows me an interface with lots of different buttons when i run it in Visual Studio 2019. Now i want to find a way to find the code belonging to a button. I already tried clicking the buttons, but nothing happens.

So my question is: How can i automatically jump to the code that is related to one of the buttons?

Thanks a lot!

Upvotes: 1

Views: 1573

Answers (1)

AwiringCameron
AwiringCameron

Reputation: 640

I am assuming that when you say "the code belonging to a button", you are referring to the code that runs when the button is clicked. In this case there are several ways of getting to this code.

In Winforms (not sure about anything else) you should be able to double click on the button and visual studio should navigate automatically to the code in the Button.Click event. If there is no Button.Click event handler for the button, it will create one.

Another way to get there is to select the button in the designer and go to the properties window(press F4). In the properties window go to the events list(see images), then double click on the "Click" event in this list and you should be directed to the code in the Button.Click event handler. If there is none, it will create one.

enter image description here enter image description here enter image description here

I hope this helps. If not, provide more details about your issue.

Upvotes: 5

Related Questions