> For the complete documentation index, see [llms.txt](https://docs-siticoneframework.gitbook.io/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-siticoneframework.gitbook.io/home/net-framework-or-net-core-ui/buttons-and-elements/siticone-copybutton/context-menu-customization.md).

# Context Menu Customization

## Overview

The Context Menu Customization feature allows developers to configure the context menu that appears when the user right‑clicks the SiticoneCopyButton. It provides options to enable or disable the context menu, modify its text, and set the font used for its items so that it aligns with the overall application design.

***

### Detailed Documentation

#### Properties & Settings

The table below outlines the customizable properties related to the context menu functionality:

| Property            | Description                                                                                                    | Default Value       | Type   | Example Usage                                            |
| ------------------- | -------------------------------------------------------------------------------------------------------------- | ------------------- | ------ | -------------------------------------------------------- |
| EnableContextMenu   | Determines whether the right‑click context menu is enabled; when disabled, right‑clicking will have no effect. | true                | bool   | `copyButton.EnableContextMenu = true;`                   |
| ContextMenuCopyText | The text displayed for the copy operation in the context menu, guiding the user to perform a copy action.      | "Copy to Clipboard" | string | `copyButton.ContextMenuCopyText = "Copy text";`          |
| ContextMenuFont     | Specifies the font used for the context menu’s text; defaults to Segoe UI, 9pt if not set by the developer.    | Segoe UI, 9pt       | Font   | `copyButton.ContextMenuFont = new Font("Segoe UI", 9F);` |

*Note: These properties directly affect the appearance and behavior of the context menu that is shown on a right‑click event.*

***

#### Code Examples and Integration Demos

**Basic Integration Example**

The following example demonstrates how to enable and customize the context menu for the SiticoneCopyButton in a simple WinForms application:

```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;

namespace ContextMenuDemo
{
    public class MainForm : Form
    {
        private SiticoneCopyButton copyButton;
        private TextBox sourceTextBox;

        public MainForm()
        {
            InitializeComponents();
        }

        private void InitializeComponents()
        {
            // Create and configure the source TextBox
            sourceTextBox = new TextBox
            {
                Location = new Point(20, 20),
                Width = 250,
                Text = "This text will be copied."
            };

            // Create and configure the SiticoneCopyButton with context menu customizations
            copyButton = new SiticoneCopyButton
            {
                Location = new Point(20, 60),
                Size = new Size(200, 40),
                Text = "Copy",
                TargetControl = sourceTextBox,
                EnableContextMenu = true,
                ContextMenuCopyText = "Copy to Clipboard",
                ContextMenuFont = new Font("Segoe UI", 9F)
            };

            // Add controls to the form
            Controls.Add(sourceTextBox);
            Controls.Add(copyButton);
        }

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new MainForm());
        }
    }
}
```

**Advanced Customization Example**

This example shows how to further customize the context menu to match a branded application by changing the font and context menu item text:

```csharp
using System;
using System.Drawing;
using System.Windows.Forms;
using SiticoneNetFrameworkUI;

namespace AdvancedContextMenuDemo
{
    public class CustomForm : Form
    {
        private SiticoneCopyButton copyButton;
        private TextBox demoTextBox;

        public CustomForm()
        {
            InitializeComponents();
        }

        private void InitializeComponents()
        {
            demoTextBox = new TextBox
            {
                Location = new Point(30, 30),
                Width = 300,
                Text = "Custom context menu demo text."
            };

            // Configure the copy button with a customized context menu
            copyButton = new SiticoneCopyButton
            {
                Location = new Point(30, 80),
                Size = new Size(250, 50),
                Text = "Advanced Copy",
                TargetControl = demoTextBox,
                EnableContextMenu = true,
                ContextMenuCopyText = "Copy This Text",
                ContextMenuFont = new Font("Calibri", 10F, FontStyle.Italic)
            };

            Controls.Add(demoTextBox);
            Controls.Add(copyButton);
        }

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new CustomForm());
        }
    }
}
```

***

### Key Points

| Aspect                  | Details                                                                                                     |
| ----------------------- | ----------------------------------------------------------------------------------------------------------- |
| Context Menu Toggle     | The EnableContextMenu property allows developers to disable the context menu if it is not needed.           |
| Customizable Menu Text  | ContextMenuCopyText enables clear labeling of the copy action to suit application language and style.       |
| Consistent Menu Styling | ContextMenuFont ensures that the context menu’s appearance remains consistent with the application’s theme. |

***

### Best Practices

| Practice                         | Recommendation                                                                                                            |
| -------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| Uniform UI Elements              | Use ContextMenuFont to match the overall application font for a seamless user experience.                                 |
| Clear Action Text                | Choose a descriptive ContextMenuCopyText that clearly informs users of the copy operation.                                |
| Enable/Disable Based on Use Case | Disable the context menu (EnableContextMenu = false) if your application does not require additional right‑click options. |

***

### Common Pitfalls

| Issue                             | Explanation                                                                                      | Avoidance Strategy                                                               |
| --------------------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
| Inconsistent Styling              | Using a font or text style for the context menu that clashes with the main application design.   | Set ContextMenuFont and ContextMenuCopyText in alignment with overall UI design. |
| Context Menu Not Appearing        | If EnableContextMenu is set to false, right‑click events will not trigger the context menu.      | Confirm EnableContextMenu is true when a context menu is desired.                |
| Hard-Coded Values Without Testing | Using fixed values without testing may result in poor readability on different display settings. | Test context menu appearance on various resolutions and DPI settings.            |

***

### Usage Scenarios

| Scenario                           | Description                                                                                  | Sample Configuration                                                                               |
| ---------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| Standard Right‑Click Copy          | For applications where a simple right‑click copy option is desired.                          | EnableContextMenu = true; use default ContextMenuCopyText and ContextMenuFont settings.            |
| Branded Application Context Menu   | When the context menu must match specific branding, customize the font and text accordingly. | Set ContextMenuFont to a branded font (e.g., Calibri, 10F, Italic) and adjust ContextMenuCopyText. |
| Minimalist UI with No Context Menu | In cases where the context menu might distract from a clean design, disable it entirely.     | Set EnableContextMenu = false to remove the right‑click menu functionality.                        |

***

### Review

| Aspect                    | Considerations                                                                                                       |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------- |
| Integration Ease          | The context menu properties are straightforward to configure and integrate into WinForms applications.               |
| Customization Flexibility | Developers have granular control over the menu’s appearance and text, ensuring consistency with application design.  |
| User Interaction          | Provides an alternative method for triggering copy operations, enhancing usability through right‑click interactions. |

***

### Summary

| Summary Point            | Description                                                                                                                     |
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| Tailored Context Menu    | The Context Menu Customization feature allows developers to easily enable, style, and modify the context menu for copy actions. |
| Flexible Integration     | With simple property settings, the context menu can be adapted to match different design themes and user requirements.          |
| Enhanced User Experience | By offering a clear and consistent right‑click copy option, this feature contributes to an overall intuitive UI.                |

***

### Additional Useful Sections

#### Integration Checklist

| Item                           | Check                                                                                                                   |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| Enable or Disable Context Menu | Ensure that EnableContextMenu is set appropriately for the intended user interaction.                                   |
| Verify Menu Text               | Confirm that ContextMenuCopyText accurately describes the copy operation and fits within the design language.           |
| Align Context Menu Font        | Set ContextMenuFont to a font that matches the application's overall style and test its legibility on various displays. |
| Test on Multiple Resolutions   | Validate that the context menu appears correctly on different screen resolutions and DPI settings.                      |

#### Troubleshooting

| Problem                       | Potential Cause                                                                                      | Suggested Fix                                                                         |
| ----------------------------- | ---------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
| Context Menu Does Not Appear  | EnableContextMenu might be set to false or the right‑click event is not properly captured.           | Verify that EnableContextMenu is true and test right‑click behavior on the control.   |
| Inconsistent Font Appearance  | The ContextMenuFont may not be set or might conflict with system defaults.                           | Explicitly set ContextMenuFont to a consistent value and test across various systems. |
| Incorrect Menu Text Displayed | The ContextMenuCopyText may be overridden elsewhere in the code or not updated after initialization. | Ensure that ContextMenuCopyText is assigned before the control is rendered.           |

***

By following this extensive documentation and using the provided code examples, developers can efficiently integrate and customize the Context Menu Customization feature of the SiticoneCopyButton control. This feature empowers you to provide users with an alternative, clearly branded method to perform copy operations via right‑click interactions in your WinForms applications.
