DesignerRegionMouseEventArgs 类

定义

ViewEvent 事件提供数据,单击选定的控件或选定控件中的设计器区域时引发此事件。Provides data for a ViewEvent event that is raised when you click on a selected control or a designer region in a selected control. 此类不能被继承。This class cannot be inherited.

public ref class DesignerRegionMouseEventArgs sealed : EventArgs
public sealed class DesignerRegionMouseEventArgs : EventArgs
type DesignerRegionMouseEventArgs = class
    inherit EventArgs
Public NotInheritable Class DesignerRegionMouseEventArgs
Inherits EventArgs
继承
DesignerRegionMouseEventArgs

示例

下面的代码示例演示如何使用DesignerRegionMouseEventArgs来标识单击的区域并相应地更改视图。The following code example shows how to use the DesignerRegionMouseEventArgs to identify the region that was clicked and to change the view accordingly. 此示例是为EditableDesignerRegion类提供的更大示例的一部分。This example is part of a larger example provided for the EditableDesignerRegion class.

// Handler for the Click event, which provides the region in the arguments.
protected override void OnClick(DesignerRegionMouseEventArgs e)
{
    if (e.Region == null)
        return;

    // If the clicked region is not a header, return
    if (e.Region.Name.IndexOf("Header") != 0)
        return;

    // Switch the current view if required
    if (e.Region.Name.Substring(6, 1) != myControl.CurrentView.ToString())
    {
        myControl.CurrentView = int.Parse(e.Region.Name.Substring(6, 1));
        base.UpdateDesignTimeHtml();
    }
}
' Handler for the Click event, which provides the region in the arguments.
Protected Overrides Sub OnClick(ByVal e As DesignerRegionMouseEventArgs)
    If IsNothing(e.Region) Then
        Return
    End If

    ' If the clicked region is not a header, return
    If e.Region.Name.IndexOf("Header") <> 0 Then
        Return
    End If

    ' Switch the current view if required
    If e.Region.Name.Substring(6, 1) <> myControl.CurrentView.ToString() Then
        myControl.CurrentView = Integer.Parse(e.Region.Name.Substring(6, 1))
        MyBase.UpdateDesignTimeHtml()
    End If
End Sub

注解

ViewEvent事件由设计器宿主为设计图面上的控件上的某些操作引发。The ViewEvent event is raised by the designer host for certain actions on a control on the design surface. 例如, 在设计图面上单击选定控件或选定控件中的设计器区域时, 将引发事件。For example, an event is raised when you click a selected control or a designer region in a selected control on the design surface.

类提供用于处理事件的ViewEvent默认委托。 ControlDesignerThe ControlDesigner class supplies a default delegate to handle the ViewEvent event. 当在设计时单击选定控件或选定控件的设计器区域时, ViewEventArgs设计器宿主会Click为事件类型初始化对象, 然后使用DesignerRegionMouseEventArgs对象设置该EventArgs属性。When you click a selected control or a designer region of a selected control at design time, the designer host initializes a ViewEventArgs object for a Click event type, and then sets the EventArgs property with a DesignerRegionMouseEventArgs object.

当对象指示您单击了设计器区域时, ControlDesigner类中的默认委托将DesignerRegionMouseEventArgs对象OnClick传递给方法。 ViewEventArgsWhen the ViewEventArgs object indicates that you clicked a designer region, the default delegate in the ControlDesigner class passes the DesignerRegionMouseEventArgs object to the OnClick method. ControlDesigner类派生的类将OnClick重写方法, 以处理在设计宿主中单击控件时引发的事件。Classes deriving from the ControlDesigner class override the OnClick method to process events that are raised when you click a control in the design host.

Region属性表示应用了事件的控件设计器区域 (如果有)。The Region property represents the control designer region that the event applies to, if any. Location属性表示设计图面上单击的位置。The Location property represents the location on the design surface that was clicked.

有关事件和委托的详细信息, 请参阅处理和引发事件For more information about events and delegates, see Handling and Raising Events.

构造函数

DesignerRegionMouseEventArgs(DesignerRegion, Point)

使用指定的区域和位置初始化 DesignerRegionMouseEventArgs 类的新实例。Initializes a new instance of the DesignerRegionMouseEventArgs class with the specified region and location.

属性

Location

获取被单击的控件内的位置。Gets the location within the control that was clicked.

Region

获取被单击的设计器区域(如果有)。Gets the designer region that was clicked, if any.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅