Visual Studio 2010显示来自代码的可用事件

时间:2022-08-25 21:53:00

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?

在工作和家里我安装了VS2010。但在工作中我有一个很酷的功能。在代码隐藏文件后面我有两个下拉菜单。当我在左边选择一个对象时,可以说是testButton或者是Default2(一个页面类),在右边的一个中,我得到该对象的所有可用事件,当我选择一个事件时,Visual Studio会在我的代码隐藏文件中自动生成它。在我的家VS我实际上有2次下降,但他们的工作不同。我在右边有可用的对象但是当我选择例如testButton时它会向我显示aspx页面并指向这个按钮:/我应该在VS配置中设置sommething还是在工作中我有一些我不知道的插件的?有任何想法吗?

Visual Studio 2010显示来自代码的可用事件

9 个解决方案

#1


10  

This is not a VB-exclusive feature.

这不是VB独有的功能。

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.

您正在寻找的是一个导航栏。在Visual Studio选项中,打开文本编辑器→C#→常规,您将看到一个名为导航栏的选项。启用它并单击“确定”。

Visual Studio 2010显示来自代码的可用事件

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.

但是,我相信这个栏在VB和C#中的工作方式有点不同。在C#中,它只列出现有的类及其方法;在VB中,它将列出所有控件及其事件,即使这些控件及其事件尚不存在。

#2


7  

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 :/

好的,我想我找到了答案。似乎此功能仅在当前文件位于VB.Net中时可用。在我看来这个suks:/

#3


6  

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

#4


4  

@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...

@shin是正确的,这是一个仅限VB.NET的功能;微软只有反馈报告可以追溯到2004年提到这个功能,所以我已经向微软提出了一个新的错误请求;并在UserVoice上添加了对Visual Studios帐户的反馈...

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.

我不喜欢C#没有提供这么有用的省时功能。

#5


2  

It is most certainly is a VB only feature and has been reported on numerous occassions to Microsoft.

它肯定是一个仅限VB的功能,并且已经在微软的许多场合报道过。

#6


1  

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.

可以在C#和Asp.net中查看所有可用的事件,但不能在VB中尽可能在代码窗口内查看。但您可以在其属性窗口中查看任何选定控件的所有事件。打开属性,然后单击事件。

#7


1  

  1. Up to Visual Studio 2010, only Vb.net has this feature: on code-behind page, the code panel upper-left drop down shows a control's name, and the right drop down shows this control's available events. When clicking this event we can get the code-block for this event. This feature is not available in C#.

    在Visual Studio 2010中,只有Vb.net具有此功能:在代码隐藏页面上,代码面板左上角的下拉列表显示控件的名称,右下拉列表显示此控件的可用事件。单击此事件时,我们可以获取此事件的代码块。此功能在C#中不可用。

  2. Without above feature, we can still get a control's available events for both C# and Vb.net: We must select the control on the aspx page and choose the design view at the lower left corner, then on the Properties panel click the Event button (the lighting sign), then available actions will be shown, double-click the name of the event you want, the event code will be generated in code-behind.

    如果没有上述功能,我们仍然可以获得C#和Vb.net的控件可用事件:我们必须在aspx页面上选择控件并选择左下角的设计视图,然后在Properties面板上单击Event按钮(点亮标志),然后会显示可用的动作,双击你想要的事件的名称,将在代码隐藏中生成事件代码。

#8


0  

This and the feature to generate event handlers without having to switch to Design view for C# is finally coming in Visual Studio 2012. It was about time.

这个以及生成事件处理程序而不必切换到C#的Design视图的功能最终将在Visual Studio 2012中出现。这是关于时间的。

#9


0  

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.

即便是2012年的功能还不够。您仍然需要猜测页面级别事件(Init,PreRender等)以及尚未填写的文件(如Global.asax),这取决于您开始使用的模板可能有也可能没有所有事件处理程序已经指定。

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.

同意事件处理程序是VB多年来的事情之一,多年来处理的方式比C#更好。我无法计算我曾经提醒过一个C#开发人员事实上确实存在某些事件的次数。

#1


10  

This is not a VB-exclusive feature.

这不是VB独有的功能。

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.

您正在寻找的是一个导航栏。在Visual Studio选项中,打开文本编辑器→C#→常规,您将看到一个名为导航栏的选项。启用它并单击“确定”。

Visual Studio 2010显示来自代码的可用事件

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.

但是,我相信这个栏在VB和C#中的工作方式有点不同。在C#中,它只列出现有的类及其方法;在VB中,它将列出所有控件及其事件,即使这些控件及其事件尚不存在。

#2


7  

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 :/

好的,我想我找到了答案。似乎此功能仅在当前文件位于VB.Net中时可用。在我看来这个suks:/

#3


6  

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

#4


4  

@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...

@shin是正确的,这是一个仅限VB.NET的功能;微软只有反馈报告可以追溯到2004年提到这个功能,所以我已经向微软提出了一个新的错误请求;并在UserVoice上添加了对Visual Studios帐户的反馈...

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.

我不喜欢C#没有提供这么有用的省时功能。

#5


2  

It is most certainly is a VB only feature and has been reported on numerous occassions to Microsoft.

它肯定是一个仅限VB的功能,并且已经在微软的许多场合报道过。

#6


1  

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.

可以在C#和Asp.net中查看所有可用的事件,但不能在VB中尽可能在代码窗口内查看。但您可以在其属性窗口中查看任何选定控件的所有事件。打开属性,然后单击事件。

#7


1  

  1. Up to Visual Studio 2010, only Vb.net has this feature: on code-behind page, the code panel upper-left drop down shows a control's name, and the right drop down shows this control's available events. When clicking this event we can get the code-block for this event. This feature is not available in C#.

    在Visual Studio 2010中,只有Vb.net具有此功能:在代码隐藏页面上,代码面板左上角的下拉列表显示控件的名称,右下拉列表显示此控件的可用事件。单击此事件时,我们可以获取此事件的代码块。此功能在C#中不可用。

  2. Without above feature, we can still get a control's available events for both C# and Vb.net: We must select the control on the aspx page and choose the design view at the lower left corner, then on the Properties panel click the Event button (the lighting sign), then available actions will be shown, double-click the name of the event you want, the event code will be generated in code-behind.

    如果没有上述功能,我们仍然可以获得C#和Vb.net的控件可用事件:我们必须在aspx页面上选择控件并选择左下角的设计视图,然后在Properties面板上单击Event按钮(点亮标志),然后会显示可用的动作,双击你想要的事件的名称,将在代码隐藏中生成事件代码。

#8


0  

This and the feature to generate event handlers without having to switch to Design view for C# is finally coming in Visual Studio 2012. It was about time.

这个以及生成事件处理程序而不必切换到C#的Design视图的功能最终将在Visual Studio 2012中出现。这是关于时间的。

#9


0  

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.

即便是2012年的功能还不够。您仍然需要猜测页面级别事件(Init,PreRender等)以及尚未填写的文件(如Global.asax),这取决于您开始使用的模板可能有也可能没有所有事件处理程序已经指定。

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.

同意事件处理程序是VB多年来的事情之一,多年来处理的方式比C#更好。我无法计算我曾经提醒过一个C#开发人员事实上确实存在某些事件的次数。