Microsoft Visual Studio和C#:如何在视觉活动添加到控制? [英] Microsoft Visual Studio and C#: How to Visually Add Events to Controls?

查看:130
本文介绍了Microsoft Visual Studio和C#:如何在视觉活动添加到控制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也许这是一个愚蠢的问题,但对我的生活,我不能找到一个方法来做到这一点。

Perhaps this is a stupid question, but for the life of me I cannot find a way to do this.

人会如何去用C#在Microsoft Visual Studio(2008年)的形式添加事件处理程序,以控制?

How would one go about adding an event handler to a control in a form in Microsoft Visual Studio (2008) with C#?

我可以做手工,但打开Designer.cs文件的形式,但我不能找到一种方法,通过接口来做到这一点。在MSVC 6,使用C ++和MFC,你可以右键点击或其他一些动作,并找到该控制所有可能事件的列表。然后你选择它,它会弹出窗口,让您创建与该事件相关联的方法。在VB中它是更容易,你能做到这一点在code和它列在方法下拉菜单中的所有事件。

I can do it manually, but opening the Designer.cs file for the Form, but I cannot find a way to do it through the interface. In MSVC 6, with C++ and MFC, you could right click or some other action, and find a list of all the possible events for that control. Then you select it and it would bring up window letting you create a method to associate with that event. In VB it was even easier, you could do it in the code and it listed all the events in the method drop downs.

不过,我无法找到C#在2008年这种事情。智能感知帮助填写正确的方法的信息。然而,它总是会在Designer.cs文件,而不是局部的类,它应该是另一半的方法

However, I cannot find anything of the sort in 2008 with C#. Intellisense helps fill in the correct method information. However, it always creates the method in the Designer.cs file, not the other half of the partial class where it should be.

感谢您。

推荐答案

在设计器中,点击感兴趣的控制。

In the designer, click the control of interest.

在属性窗口(按下F4键来弹出),应该有一个小闪电图标。单击该图标将带您到该控件可用事件的列表。双击事件名称将线了一个存根处理程序,并带你到code-落后于它。

In the properties window (hit F4 to bring it up), there should be a little lightning bolt icon. Clicking the icon takes you to the list of available events for that control. Double-clicking the event name will wire up a stub handler and take you to the code-behind for it.

编辑:细心的读者会看到张贴的截图是一个Web应用程序(whups),但它是一个WinForms应用程序完全一样的东西。

the astute reader will see that the posted screenshot is for a web app (whups), but it's the exact same thing for a winforms app.

这篇关于Microsoft Visual Studio和C#:如何在视觉活动添加到控制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆