# TextContextMenuEventArgs Class

> The TextContextMenuEventArgs class provides data for the TextControl.TextContextMenuOpening event of a Windows Forms TextControl. This event occurs, immediately before a built-in context menu will be opened. A TextControl provides context menus for different parts of a document. The ContextMenuLocation property informs for which part the menu will be opened. The pre-defined menu provided with the TextContextMenu property can be altered or expanded.

- **Product:** TX Text Control .NET for Windows Forms
- **Section:** Reference
- **Kind:** Class
- **Introduced:** 19.0
- **Namespace:** `TXTextControl`
- **Package:** `TXTextControl.TextControl.WinForms.SDK` (assembly `TXTextControl.Windows.Forms.dll`, from the private NuGet feed or Text Control Offline Packages)
- **.NET Framework:** reference `TXTextControl.Windows.Forms.dll` from the setup
- **Inherits:** `System.ComponentModel.CancelEventArgs`
- **Path:** TX Text Control .NET for Windows Forms > Reference > TXTextControl > TextContextMenuEventArgs Class
- **747 words**
- **Web URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/
- **LLMs URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/llms-full.txt

---

### Description

The TextContextMenuEventArgs class provides data for the [TextControl.TextContextMenuOpening](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/textcontextmenuopening-event/llms-full.txt) event of a Windows Forms [TextControl](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontrol/llms-full.txt). This event occurs, immediately before a built-in context menu will be opened. A TextControl provides context menus for different parts of a document. The [ContextMenuLocation](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/contextmenulocation-property/llms-full.txt) property informs for which part the menu will be opened. The pre-defined menu provided with the [TextContextMenu](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/textcontextmenu-property/llms-full.txt) property can be altered or expanded.

### Syntax

```csharp
public class TextContextMenuEventArgs : CancelEventArgs
```

```vbnet
Public Class TextContextMenuEventArgs
    Inherits CancelEventArgs
```

### Examples

The following example uses `TextContextMenuEventArgs.ContextMenuLocation` while handling `TextContextMenuOpening`.

```csharp
textControl.TextContextMenuOpening += (_, e) =>
{
    Console.WriteLine($"Context Menu Location: {e.ContextMenuLocation}");
};
```

```vbnet
AddHandler textControl.TextContextMenuOpening,
    Sub(sender, e)
        Console.WriteLine($"Context Menu Location: {e.ContextMenuLocation}")
    End Sub
```

---

## In This Section

- [TextContextMenuEventArgs.ContextMenuLocation Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/contextmenulocation-property/llms-full.txt): Gets the location in the document for which the context menu will be opened. The context menu items, which will be shown, depend on this location. The property value can be a combination (bitwise or) of the ContextMenuLocation values.
- [TextContextMenuEventArgs.Location Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/location-property/llms-full.txt): Gets the location, in pixels, where the context menu is displayed. The coordinates are relative to the top-left corner of the screen.
- [TextContextMenuEventArgs.TextContextMenu Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/textcontextmenu-property/llms-full.txt): Gets or sets the context menu, which will be shown. The items depend on the document location where the mouse click occurs. The menu can be altered, extended or completely replaced. When this property is set to null, the TextControl uses system menu items. To completely suppress a context menu, the Cancel Property must be set the true.

---

## Nearby

- **Previous:** [TextCharCollection.Remove Method](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcharcollection/remove-method/llms-full.txt)
- **Next:** [TextContextMenuEventArgs.ContextMenuLocation Property](https://docs.textcontrol.com/tx-text-control-dotnet-winforms/reference/txtextcontrol/textcontextmenueventargs/contextmenulocation-property/llms-full.txt)
