# Custom Actions Overview

A custom action is an action that contains a collection of parameters, defined by the user, that will be evaluated during report processing. It does not affect the currently viewed report in any way - its purpose is to be used in a report viewer's interactive action event handlers: `InteractiveActionExecuting()`, `InteractiveActionEnter()`, and `InteractiveActionLeave()`.

To define a [CustomAction](https://www.telerik.com/products/reporting/documentation/api/telerik.reporting.customaction) use the [Edit Action Dialog](https://www.telerik.com/products/reporting/documentation/designing-reports/report-designer-tools/desktop-designers/tools/edit-action-dialog) or create it programmatically in the report class body.

Here is an example of how to get the custom action's parameters in the [InteractiveActionExecuting](https://www.telerik.com/products/reporting/documentation/api/telerik.reportviewer.winforms.reportviewerbase#Telerik_ReportViewer_WinForms_ReportViewerBase_InteractiveActionExecuting) event of the **WinForms Report Viewer**.

```C#

void reportViewer1_CustomInteractiveActionExecuting(object sender, Telerik.ReportViewer.Common.InteractiveActionCancelEventArgs args)
{
    var strB = new System.Text.StringBuilder();
    strB.AppendLine("ReportItem name: " + args.Action.ReportItemName);

    var customAction = args.Action as Telerik.Reporting.Processing.CustomAction;
    if (null != customAction)
    {
        foreach (var p in customAction.Parameters)
        {
            strB.AppendLine(string.Format("Parameter \"{0}\" value: {1}", p.Key, p.Value));
        }
    }

    strB.AppendLine(string.Format("Mouse cursor position: {0}; Item bounds: {1}", args.CursorPos, args.Bounds));

    MessageBox.Show(strB.ToString());
}
```

```VB.NET
' Handles the InteractiveActionExecuting event
' Do not forget to add the WithEvents clause on ReportViewer1 instantiation if needed.
Private Sub reportViewer1_CustomInteractiveActionExecuting(sender As Object, args As Telerik.ReportViewer.Common.InteractiveActionCancelEventArgs) Handles ReportViewer1.InteractiveActionExecuting

    Dim strB = New System.Text.StringBuilder()
    strB.AppendLine("ReportItem name: " + args.Action.ReportItemName)

    Dim customAction = TryCast(args.Action, Telerik.Reporting.Processing.CustomAction)
    If customAction IsNot Nothing Then
        For Each p As KeyValuePair(Of String, Object) In customAction.Parameters
            strB.AppendLine(String.Format("Parameter ""{0}"" value: {1}", p.Key, p.Value))
        Next
    End If

    strB.AppendLine(String.Format("Mouse cursor position: {0}; Item bounds: {1}", args.CursorPos, args.Bounds))

    MessageBox.Show(strB.ToString())
End Sub
```

## How to Add a Custom Action

### Adding a custom action using the Report Designer

1. In the Design view, right-click the report item to which you want to add a link and then click **Properties**.
2. In The Properties dialog box for that report item, click **Action**. The [Edit Action dialog](https://www.telerik.com/products/reporting/documentation/designing-reports/report-designer-tools/desktop-designers/tools/edit-action-dialog) will open.
3. Select **Custom**. An additional section appears in the dialog box, containing a button titled **Select parameters**.
4. Clicking the button will open the **Edit Custom Action Parameters** dialog box. Add one or more parameters, defining their *Name*  and *Value*  properties.
5. Click **OK** when ready.
6. To test the action, preview the report and click the report item with the applied custom action. A message will appear, displaying information for the action's properties.

### Adding a custom action programmatically

```C#

Telerik.Reporting.CustomAction customAction = new Telerik.Reporting.CustomAction();
customAction.Parameters.Add("param1", "=Fields.Name");
customAction.Parameters.Add("param2", "=Now()");
textBox1.Action = customAction;
```

```VB.NET

Dim customAction As New Telerik.Reporting.CustomAction()
customAction.Parameters.Add("param1", "=Fields.Name")
customAction.Parameters.Add("param2", "=Now()")
textBox1.Action = customAction
```

## See Also

* [Actions Overview](https://www.telerik.com/products/reporting/documentation/interactivity/actions/overview)
* [Interactive Action Events](https://www.telerik.com/products/reporting/documentation/interactivity/actions/interactive-action-events)
* [Expressions](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/expressions/overview)
* [Data Items](https://www.telerik.com/products/reporting/documentation/designing-reports/connecting-to-data/data-items/overview)
