.NET Framework Class Library
ControlDesignerOnClick Method

Called by the design host when the user clicks the associated control at design time.

Namespace:   System.Web.UI.Design
Assembly:  System.Design (in System.Design.dll)
Syntax
Protected Overridable Sub OnClick ( _
	e As [%$TOPIC/ms153754_en-us_VS_110_1_0_0_0_0%] _
)
protected virtual void OnClick(
	[%$TOPIC/ms153754_en-us_VS_110_1_0_1_0_0%] e
)
protected:
virtual void OnClick(
	[%$TOPIC/ms153754_en-us_VS_110_1_0_2_0_0%]^ e
)
abstract OnClick : 
        e:[%$TOPIC/ms153754_en-us_VS_110_1_0_3_0_0%] -> unit  
override OnClick : 
        e:[%$TOPIC/ms153754_en-us_VS_110_1_0_3_0_1%] -> unit

Parameters

e
Type: System.Web.UI.DesignDesignerRegionMouseEventArgs

A DesignerRegionMouseEventArgs object that specifies the location and, possibly, the control designer region that the user clicked.

Remarks

The ViewEvent event is raised by the design host for certain actions on a control in the design surface. For example, an event is raised for the following conditions:

  • The user clicks the control.

  • The control designer paints on the design surface.

  • The user enters or exits template editing mode for the control.

The ControlDesigner class supplies a default delegate to handle the IControlDesignerViewViewEvent event. Classes deriving from ControlDesigner override the OnClick method to process events that are raised when the user clicks a control.

The OnClick method allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

The default implementation of the OnClick method returns without performing any processing.

Notes to Inheritors

Override the OnClick method in a class deriving from the ControlDesigner class to handle design-time click events on the control. If e is not null, the clicked region, if any, is specified in the Region property.

Examples

The following code example shows how to use a handler for the OnClick event in a clickable region of the control and use a DesignerRegionMouseEventArgs object to identify the region that is being clicked.

This code example is part of a larger code example for the EditableDesignerRegion class.

' 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
// 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.5, 4, 3.5, 3.0, 2.0
.NET Framework Security
Platforms

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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