Eric
Eric

Reputation: 359

Events list in Visual Studio 2015

Using VS2013 it was possible, at least with VB.NET, to double click on a control and then the default event would show up in the code file. Above this there was a pull down list of the other possible events for this control.

Now I'm working in VS2015 and in C#, but that list is not there. I can still double click on a control to get the default event, but I cannot add another event. I don't think I'm supposed to edit the designer file.

How do I do this now? Do I need to add events in the code file now?

for example I want to be able to drop a file on my windows application. So somewhere I need to add the event for this.

Upvotes: 5

Views: 7007

Answers (3)

user7369583
user7369583

Reputation: 1

If you keep the mouse on the Button key word in xaml code and then click on the lightning icon, you will be able to see the click event.

Upvotes: 0

Idle_Mind
Idle_Mind

Reputation: 39132

Using VS2013 it was possible, at least with VB.NET, to double click on a control and then the default event would show up in the code file. Above this there was a pull down list of the other possible events for this control.

This is known as the Navigation Bar. You can toggle it on/off in Tools --> Options --> Text Editor --> {Select Language} --> Navigation Bar.

BUT...the Navigation Bar behaves differently in C# than it does in VB.Net. It won't do what you want in C#, sorry!

To wire up an event using the IDE in C#, you have to first select the thing in question, then go to the Properties Pane and switch it to the Events view with the "Lightning Bolt" icon as Empereur Aiman has shown in his post.

C#, however, can do something that VB.Net cannot. With C#, you can wire up an event by writing a line of code in the editor and have the IDE generate the event stub for you. For instance, in the snippet below, a dynamic button is being created:

Button btn = new Button();

If you want to wire up its Click() event, you'd type in:

btn.Click +=

After the equals sign = is typed, you'd press {Tab} and the event stub will be generated for you:

    private void Btn_Click(object sender, EventArgs e)
    {
        throw new NotImplementedException();
    }

Upvotes: 5

wingerse
wingerse

Reputation: 3796

Winforms :
enter image description here

Wpf:
enter image description here
To see the properties window:
enter image description here

Upvotes: 7

Related Questions