在 Windows 窗体中创建事件处理程序Creating Event Handlers in Windows Forms

事件处理程序是代码中的过程,用于确定事件(例如用户单击按钮或消息队列收到消息)发生时要执行的操作。An event handler is a procedure in your code that determines what actions are performed when an event occurs, such as when the user clicks a button or a message queue receives a message. 引发事件时,将执行收到该事件的一个或多个事件处理程序。When an event is raised, the event handler or handlers that receive the event are executed. 可以将事件分配给多个处理程序,并且可以动态更改处理特定事件的方法。Events can be assigned to multiple handlers, and the methods that handle particular events can be changed dynamically. 您可以在 Visual Studio 中使用 Windows 窗体设计器创建事件处理程序。You can also use the Windows Forms Designer in Visual Studio to create event handlers.

本节内容In This Section

事件概述\Events Overview\ 解释事件模型和委托的角色。Explains the event model and the role of delegates.

事件处理程序概述\Event Handlers Overview\ 描述如何处理事件。Describes how to handle events.

如何:在运行时为 Windows 窗体创建事件处理程序\How to: Create Event Handlers at Run Time for Windows Forms\ 提供有关如何动态响应系统或用户事件的指令。Gives directions for responding to system or user events dynamically.

如何:将多个事件连接到 Windows 窗体中的单个事件处理程序\How to: Connect Multiple Events to a Single Event Handler in Windows Forms\ 提供有关通过事件将同一功能分配给多个控件的指令。Gives directions for assigning the same functionality to multiple controls through events.

Windows 窗体中的事件顺序\Order of Events in Windows Forms\ 描述在 Windows 窗体控件中引发事件的顺序。Describes the order in which events are raised in Windows Forms controls.

如何:创建使用事件处理程序在设计器介绍如何使用 Windows 窗体设计器创建事件处理程序。How to: Create Event Handlers Using the Designer Describes how to use the Windows Forms Designer to create event handlers.

事件\Events\ 提供的处理和引发事件使用.NET Framework 的主题的链接。Provides links to topics on handling and raising events using the .NET Framework.

有关 Visual Basic 中继承的事件处理程序的疑难解答\Troubleshooting Inherited Event Handlers in Visual Basic\ 列出了继承的组件中的事件处理程序所发生的常见问题。Lists common issues that occur with event handlers in inherited components.