vb.net Visual Studio 2015 中的事件列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32873421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Events list in Visual Studio 2015
提问by Eric
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.
使用 VS2013,至少在 VB.NET 中,双击控件是可能的,然后默认事件将显示在代码文件中。在此之上有一个此控件的其他可能事件的下拉列表。
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.
现在我在 VS2015 和 C# 中工作,但该列表不存在。我仍然可以双击控件来获取默认事件,但我无法添加另一个事件。我认为我不应该编辑设计器文件。
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.
例如,我希望能够在我的 Windows 应用程序上放置一个文件。所以在某处我需要为此添加事件。
回答by Idle_Mind
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.
使用 VS2013,至少在 VB.NET 中,双击控件是可能的,然后默认事件将显示在代码文件中。在此之上有一个此控件的其他可能事件的下拉列表。
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 differentlyin C# than it does in VB.Net. It won't do what you want in C#, sorry!
但是……导航栏在 C# 中的行为与在 VB.Net 中的行为不同。它不会在 C# 中执行您想要的操作,抱歉!
To wire up an event using the IDEin 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# 中的 IDE 连接事件,您必须首先选择有问题的事物,然后转到属性窗格并将其切换到带有“闪电”图标的事件视图,如 Empereur Aiman 在他的帖子中所示。
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:
然而,C# 可以做一些 VB.Net 做不到的事情。使用 C#,您可以通过在编辑器中编写一行代码来连接事件,并让 IDE为您生成事件存根。例如,在下面的代码段中,正在创建一个动态按钮:
Button btn = new Button();
If you want to wire up its Click() event, you'd type in:
如果你想连接它的 Click() 事件,你需要输入:
btn.Click +=
After the equals sign =is typed, you'd press {Tab} and the event stub will be generated for you:
=输入等号后,您可以按 {Tab} 并为您生成事件存根:
private void Btn_Click(object sender, EventArgs e)
{
throw new NotImplementedException();
}
回答by user7369583
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.
如果将鼠标一直放在xaml代码中的Button关键字上,然后点击闪电图标,就能看到点击事件。


