DesignerRegionMouseEventArgs Class (System.Web.UI.Design)

Switch View :
ScriptFree
.NET Framework Class Library
DesignerRegionMouseEventArgs Class

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.

Inheritance Hierarchy

System.Object
  System.EventArgs
    System.Web.UI.Design.DesignerRegionMouseEventArgs

Namespace:  System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)
Syntax

Visual Basic
Public NotInheritable Class DesignerRegionMouseEventArgs _
	Inherits EventArgs
C#
public sealed class DesignerRegionMouseEventArgs : EventArgs
Visual C++
public ref class DesignerRegionMouseEventArgs sealed : public EventArgs
F#
[<Sealed>]
type DesignerRegionMouseEventArgs =  
    class
        inherit EventArgs
    end

The DesignerRegionMouseEventArgs type exposes the following members.

Constructors

  Name Description
Public method DesignerRegionMouseEventArgs Initializes a new instance of the DesignerRegionMouseEventArgs class with the specified region and location.
Top
Properties

  Name Description
Public property Location Gets the location within the control that was clicked.
Public property Region Gets the designer region that was clicked, if any.
Top
Methods

  Name Description
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
Remarks

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.

The ControlDesigner class supplies a default delegate to handle the ViewEvent event. 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.

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

The Region property represents the control designer region that the event applies to, if any. The Location property represents the location on the design surface that was clicked.

For more information about events and delegates, see Events and Delegates.

Examples

The following code example shows how to use the DesignerRegionMouseEventArgs to identify the region that was clicked and to change the view accordingly. This example is part of a larger example provided for the EditableDesignerRegion class.

Visual Basic

' 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


C#

// 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();
    }
}


Version Information

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0
Platforms

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
See Also

Reference