mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 09:06:04 +02:00
* Merge winforms framework content to working branch (#14) * Breadcrumb / TOC / Move net5 to net folder (#15) * change path from net5 to net * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Mess with bread/toc * Add .net 5 winforms placeholder article (#16) * added some metadata and adjusted net5 placeholder * corrections * corrections * corrections * Test1 * Swapping landing page vs concept * fix links * Fix links * Fix desc
2.2 KiB
2.2 KiB
title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
| title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| How to: Associate a ContextMenuStrip with a Control | 03/30/2017 |
|
|
6fc40a42-5d69-427f-aa30-0a146193226b |
How to: Associate a ContextMenuStrip with a Control
After creating your controls and shortcut menus, use the following procedures to display a given shortcut menu when the user right-clicks the control. These procedures associate a xref:System.Windows.Forms.ContextMenuStrip with a Windows Form and with a xref:System.Windows.Forms.ToolStrip control.
To associate a ContextMenuStrip with a Windows Form
- Set the xref:System.Windows.Forms.Control.ContextMenuStrip%2A property to the name of the associated xref:System.Windows.Forms.ContextMenuStrip.
To associate a ContextMenuStrip with a ToolStrip control
- Set the control's xref:System.Windows.Forms.Control.ContextMenuStrip%2A property to the name of the associated xref:System.Windows.Forms.ContextMenuStrip.
Example
The following code example creates a Windows Form and a xref:System.Windows.Forms.ToolStrip, and associates a different xref:System.Windows.Forms.ContextMenuStrip control with each of them.
[!code-csharpSystem.Windows.Forms.ContextMenuStrip#1] [!code-vbSystem.Windows.Forms.ContextMenuStrip#1]
Compiling the Code
This example requires:
- References to the System, System.Data, System.Drawing and System.Windows.Forms assemblies.