Visual studio 2010 showing available events from c

2019-01-18 03:54发布

In work and in home I have VS2010 installed. But in work I have this one cool feature. On the code behind file I have two drop downs. When I select some object in the left one lets say a testButton or Default2 (a page class), on the right one I get all available events for that object and when I select an event Visual Studio autogenerates it in my code-behind file. In my home VS I actually have does 2 drop downs but they work different. I have available objects on the right one but when I select for example the testButton it shows me the aspx page and points this button :/ Should I set sommething in the VS configuration or maybe in work I have some addon which I'm not aware of? Any ideas?

enter image description here

9条回答
祖国的老花朵
2楼-- · 2019-01-18 04:16

This is not a VB-exclusive feature.

What you're looking for is called a navigation bar. In Visual Studio options, open Text Editor → C# → General, and you'll see an option called Navigation Bar. Enable it and click OK.

Navigation bar in Options

However, I believe this bar works a bit differently in VB and in C#. In C#, it only lists the existing classes and their methods; in VB, it will list all your controls and their events even if those don't exist yet.

查看更多
放我归山
3楼-- · 2019-01-18 04:18

You need to go the design view, in the Properties box, click on Events (lighting bolt) and double click on the events you want to code behind:

http://www.byte.net/images/c-sharp-events-code-behind.png

查看更多
Emotional °昔
4楼-- · 2019-01-18 04:20

Even the 2012 feature is not enough. You still have to guess for Page level events (Init, PreRender, etc) and also files that haven't already been filled out for you like Global.asax, which depending on the template you started with may or may not have all the event handlers already specified.

Agreed that Event Handlers is one of the things VB has for years and years and years handled way better than C#. I can't count the number of times I've had to remind a fellow C# developer that some events do, in fact, exist.

查看更多
放荡不羁爱自由
5楼-- · 2019-01-18 04:24

@shin is correct, this is a VB.NET only feature; Microsoft only had feedback reports dating back to 2004 mentioning this feature, so I have opened a new bug request with Microsoft regarding this; and also added feedback to Visual Studios account on UserVoice...

https://connect.microsoft.com/VisualStudio/feedback/details/688175/vs2010-c-add-page-event-handlers-to-asp-net-using-codebehind-navigation-bar-the-same-way-as-in-vb-net

http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/2244558-allow-c-to-add-event-handlers-to-classes-using-co

I encourage everyone who this issue effects to go and vote up & confirm this issue with them.

I dislike that C# doesn't provide such a useful time-saving function.

查看更多
贪生不怕死
6楼-- · 2019-01-18 04:24

It is possible to see all the available Events in C# & Asp.net too, but not inside code window as possible in VB. But you can see all Events of any selected Control in its Property Window. Open Properties, then Click Events.

查看更多
放我归山
7楼-- · 2019-01-18 04:27

Ok I think I've found the answer. It seems that this feature is only available when the current file is in VB.Net. In my opinion this suks :/

查看更多
登录 后发表回答