-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathContextMenu.xml
520 lines (468 loc) · 43.2 KB
/
ContextMenu.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
<Type Name="ContextMenu" FullName="System.Windows.Forms.ContextMenu">
<TypeSignature Language="C#" Value="public class ContextMenu : System.Windows.Forms.Menu" />
<TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ContextMenu extends System.Windows.Forms.Menu" />
<TypeSignature Language="DocId" Value="T:System.Windows.Forms.ContextMenu" />
<TypeSignature Language="VB.NET" Value="Public Class ContextMenu
Inherits Menu" />
<TypeSignature Language="F#" Value="type ContextMenu = class
 inherit Menu" />
<TypeSignature Language="C++ CLI" Value="public ref class ContextMenu : System::Windows::Forms::Menu" />
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Base>
<BaseTypeName>System.Windows.Forms.Menu</BaseTypeName>
</Base>
<Interfaces />
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DefaultEvent("Popup")]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultEvent("Popup")>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="windowsdesktop-10.0">
<AttributeName Language="C#">[System.ComponentModel.Browsable(false)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.Browsable(false)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="windowsdesktop-10.0">
<AttributeName Language="C#">[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="windowsdesktop-10.0">
<AttributeName Language="C#">[System.Obsolete("`ContextMenu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `ContextMenuStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")]</AttributeName>
<AttributeName Language="F#">[<System.Obsolete("`ContextMenu` is provided for binary compatibility with .NET Framework and is not intended to be used directly from your code. Use `ContextMenuStrip` instead.", false, DiagnosticId="WFDEV006", UrlFormat="https://aka.ms/winforms-warnings/{0}")>]</AttributeName>
</Attribute>
</Attributes>
<Docs>
<summary>Represents a shortcut menu.
This class is not available in .NET Core 3.1 and later versions. Use <see cref="T:System.Windows.Forms.ContextMenuStrip" /> instead, which replaces and extends the <see cref="T:System.Windows.Forms.ContextMenu" /> control.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This class is not available in .NET Core 3.1 and later versions. Use <xref:System.Windows.Forms.ContextMenuStrip> instead.
The <xref:System.Windows.Forms.ContextMenu> class represents shortcut menus that can be displayed when the user clicks the right mouse button over a control or area of the form. Shortcut menus are typically used to combine different menu items from a <xref:System.Windows.Forms.MainMenu> of a form that are useful for the user given the context of the application. For example, you can use a shortcut menu assigned to a <xref:System.Windows.Forms.TextBox> control to provide menu items for changing the font of the text, finding text within the control, or Clipboard features for copying and pasting text. You can also display new <xref:System.Windows.Forms.MenuItem> objects in a shortcut menu that are not located within a <xref:System.Windows.Forms.MainMenu> to provide situation specific commands that are not appropriate for the <xref:System.Windows.Forms.MainMenu> to display.
Typically, a shortcut menu is displayed when a user clicks the right mouse button over a control or the form itself. Visible controls and <xref:System.Windows.Forms.Form> have a <xref:System.Windows.Forms.Control.ContextMenu%2A> property that binds the <xref:System.Windows.Forms.ContextMenu> class to the control that displays the shortcut menu. More than one control can use a <xref:System.Windows.Forms.ContextMenu>. You can use the <xref:System.Windows.Forms.ContextMenu.SourceControl%2A> property to determine which control last displayed the shortcut menu in order to perform tasks specific to the control or to modify the shortcut menu displayed for the control.
You might want to know when the shortcut menu is being displayed in order to set check marks, disable items, and perform other menu tasks before the menu is displayed to the user. You can handle the <xref:System.Windows.Forms.ContextMenu.Popup> event to determine when the shortcut menu is being displayed.
> [!NOTE]
> In order to reuse <xref:System.Windows.Forms.MenuItem> objects that are displayed in a <xref:System.Windows.Forms.MainMenu> for use in a <xref:System.Windows.Forms.ContextMenu>, you must create a copy of the menu using the <xref:System.Windows.Forms.MenuItem.CloneMenu%2A> method of the <xref:System.Windows.Forms.MenuItem> class. You can also merge menu items and their submenu items into a single <xref:System.Windows.Forms.MenuItem> object using the <xref:System.Windows.Forms.MenuItem.MergeMenu%2A> method of the <xref:System.Windows.Forms.MenuItem> class.
## Examples
The following code example creates an event handler for the <xref:System.Windows.Forms.ContextMenu.Popup> event of the <xref:System.Windows.Forms.ContextMenu>. The code in the event handler determines which of two controls a <xref:System.Windows.Forms.PictureBox> named `pictureBox1` and a <xref:System.Windows.Forms.TextBox> named `textBox1` is the control displaying the shortcut menu. Depending on which control caused the <xref:System.Windows.Forms.ContextMenu> to display its shortcut menu, the control adds the appropriate <xref:System.Windows.Forms.MenuItem> objects to the <xref:System.Windows.Forms.ContextMenu>. This example requires that you have an instance of the <xref:System.Windows.Forms.ContextMenu> class, named `contextMenu1`, defined within the form. This example also requires that you have a <xref:System.Windows.Forms.TextBox> and <xref:System.Windows.Forms.PictureBox> added to a form and that the <xref:System.Windows.Forms.Control.ContextMenu%2A> property of these controls is set to `contextMenu1`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic ContextMenu Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenu/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic ContextMenu Example/VB/source.vb" id="Snippet1":::
]]></format>
</remarks>
<altmember cref="T:System.Windows.Forms.Menu" />
<altmember cref="T:System.Windows.Forms.MenuItem" />
<altmember cref="T:System.Windows.Forms.MainMenu" />
</Docs>
<Members>
<MemberGroup MemberName=".ctor">
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Forms.ContextMenu" /> class.</summary>
</Docs>
</MemberGroup>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ContextMenu ();" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor() cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.#ctor" />
<MemberSignature Language="VB.NET" Value="Public Sub New ()" />
<MemberSignature Language="C++ CLI" Value="public:
 ContextMenu();" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters />
<Docs>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Forms.ContextMenu" /> class with no menu items specified.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Once you have used this version of the constructor, you can add menu items to the <xref:System.Windows.Forms.ContextMenu> by using the <xref:System.Windows.Forms.Menu.MenuItemCollection.Add%2A> method of the <xref:System.Windows.Forms.Menu.MenuItemCollection> class. You can access the <xref:System.Windows.Forms.Menu.MenuItemCollection> through the <xref:System.Windows.Forms.Menu.MenuItems%2A> property.
]]></format>
</remarks>
<altmember cref="T:System.Windows.Forms.Menu.MenuItemCollection" />
</Docs>
</Member>
<Member MemberName=".ctor">
<MemberSignature Language="C#" Value="public ContextMenu (System.Windows.Forms.MenuItem[] menuItems);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class System.Windows.Forms.MenuItem[] menuItems) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.#ctor(System.Windows.Forms.MenuItem[])" />
<MemberSignature Language="VB.NET" Value="Public Sub New (menuItems As MenuItem())" />
<MemberSignature Language="F#" Value="new System.Windows.Forms.ContextMenu : System.Windows.Forms.MenuItem[] -> System.Windows.Forms.ContextMenu" Usage="new System.Windows.Forms.ContextMenu menuItems" />
<MemberSignature Language="C++ CLI" Value="public:
 ContextMenu(cli::array <System::Windows::Forms::MenuItem ^> ^ menuItems);" />
<MemberType>Constructor</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Parameters>
<Parameter Name="menuItems" Type="System.Windows.Forms.MenuItem[]" />
</Parameters>
<Docs>
<param name="menuItems">An array of <see cref="T:System.Windows.Forms.MenuItem" /> objects that represent the menu items to add to the shortcut menu.</param>
<summary>Initializes a new instance of the <see cref="T:System.Windows.Forms.ContextMenu" /> class with a specified set of <see cref="T:System.Windows.Forms.MenuItem" /> objects.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
You can use this version of the constructor to create a <xref:System.Windows.Forms.ContextMenu> that has its menu items specified at the time it is created. Once you have used this version of the constructor, you can add additional menu items to the <xref:System.Windows.Forms.ContextMenu> by using the <xref:System.Windows.Forms.Menu.MenuItemCollection.Add%2A> method of the <xref:System.Windows.Forms.Menu.MenuItemCollection> class. You can access the <xref:System.Windows.Forms.Menu.MenuItemCollection> through the <xref:System.Windows.Forms.Menu.MenuItems%2A> property.
## Examples
The following code example demonstrates constructing a shortcut menu and using the <xref:System.Windows.Forms.ContextMenu.Show%2A> method. To run the example, paste the following code in a form containing a button named Button1. Ensure all events are associated with their event-handling methods.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ManualContextMenu/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenu/.ctor/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ManualContextMenu/VB/form1.vb" id="Snippet1":::
]]></format>
</remarks>
<altmember cref="T:System.Windows.Forms.MenuItem" />
</Docs>
</Member>
<Member MemberName="Collapse">
<MemberSignature Language="C#" Value="public event EventHandler Collapse;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler Collapse" />
<MemberSignature Language="DocId" Value="E:System.Windows.Forms.ContextMenu.Collapse" />
<MemberSignature Language="VB.NET" Value="Public Custom Event Collapse As EventHandler " />
<MemberSignature Language="F#" Value="member this.Collapse : EventHandler " Usage="member this.Collapse : System.EventHandler " />
<MemberSignature Language="C++ CLI" Value="public:
 event EventHandler ^ Collapse;" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs when the shortcut menu collapses.</summary>
<remarks>
<format type="text/markdown"><.
## Examples
The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the <xref:System.Windows.Forms.ContextMenu.Collapse> event. This report helps you to learn when the event occurs and can assist you in debugging. To report on multiple events or on events that occur frequently, consider replacing <xref:System.Windows.Forms.MessageBox.Show%2A?displayProperty=nameWithType> with <xref:System.Console.WriteLine%2A?displayProperty=nameWithType> or appending the message to a multiline <xref:System.Windows.Forms.TextBox>.
To run the example code, paste it into a project that contains an instance of type <xref:System.Windows.Forms.ContextMenu> named `ContextMenu1`. Then ensure that the event handler is associated with the <xref:System.Windows.Forms.ContextMenu.Collapse> event.
:::code language="csharp" source="~/snippets/csharp/System.ComponentModel/CollectionChangeEventArgs/Overview/EventExamples.cs" id="Snippet170":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.EventExamples/VB/EventExamples.vb" id="Snippet170":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="OnCollapse">
<MemberSignature Language="C#" Value="protected internal virtual void OnCollapse (EventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig newslot virtual instance void OnCollapse(class System.EventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.OnCollapse(System.EventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overridable Sub OnCollapse (e As EventArgs)" />
<MemberSignature Language="F#" Value="abstract member OnCollapse : EventArgs -> unit
override this.OnCollapse : EventArgs -> unit" Usage="contextMenu.OnCollapse e" />
<MemberSignature Language="C++ CLI" Value="protected public:
 virtual void OnCollapse(EventArgs ^ e);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.EventArgs" Index="0" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
</Parameters>
<Docs>
<param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
<summary>Raises the <see cref="E:System.Windows.Forms.ContextMenu.Collapse" /> event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="OnPopup">
<MemberSignature Language="C#" Value="protected internal virtual void OnPopup (EventArgs e);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig newslot virtual instance void OnPopup(class System.EventArgs e) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.OnPopup(System.EventArgs)" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overridable Sub OnPopup (e As EventArgs)" />
<MemberSignature Language="F#" Value="abstract member OnPopup : EventArgs -> unit
override this.OnPopup : EventArgs -> unit" Usage="contextMenu.OnPopup e" />
<MemberSignature Language="C++ CLI" Value="protected public:
 virtual void OnPopup(EventArgs ^ e);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="e" Type="System.EventArgs" />
</Parameters>
<Docs>
<param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
<summary>Raises the <see cref="E:System.Windows.Forms.ContextMenu.Popup" /> event.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="Popup">
<MemberSignature Language="C#" Value="public event EventHandler Popup;" />
<MemberSignature Language="ILAsm" Value=".event class System.EventHandler Popup" />
<MemberSignature Language="DocId" Value="E:System.Windows.Forms.ContextMenu.Popup" />
<MemberSignature Language="VB.NET" Value="Public Custom Event Popup As EventHandler " />
<MemberSignature Language="F#" Value="member this.Popup : EventHandler " Usage="member this.Popup : System.EventHandler " />
<MemberSignature Language="C++ CLI" Value="public:
 event EventHandler ^ Popup;" />
<MemberType>Event</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.EventHandler</ReturnType>
</ReturnValue>
<Docs>
<summary>Occurs before the shortcut menu is displayed.</summary>
<remarks>
<format type="text/markdown"><.
## Examples
The following code example creates an event handler for the <xref:System.Windows.Forms.ContextMenu.Popup> event of the <xref:System.Windows.Forms.ContextMenu>. The code in the event handler determines which of two controls a <xref:System.Windows.Forms.PictureBox> named `pictureBox1` and a <xref:System.Windows.Forms.TextBox> named `textBox1` is the control displaying the shortcut menu. Depending on which control caused the <xref:System.Windows.Forms.ContextMenu> to display its shortcut menu, the control adds the appropriate <xref:System.Windows.Forms.MenuItem> objects to the <xref:System.Windows.Forms.ContextMenu>. This example requires that you have an instance of the <xref:System.Windows.Forms.ContextMenu> class, named `contextMenu1`, defined within the form. This example also requires that you have a <xref:System.Windows.Forms.TextBox> and <xref:System.Windows.Forms.PictureBox> added to a form and that the <xref:System.Windows.Forms.Control.ContextMenu%2A> property of these controls is set to `contextMenu1`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic ContextMenu Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenu/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic ContextMenu Example/VB/source.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
<Member MemberName="ProcessCmdKey">
<MemberSignature Language="C#" Value="protected internal virtual bool ProcessCmdKey (ref System.Windows.Forms.Message msg, System.Windows.Forms.Keys keyData, System.Windows.Forms.Control control);" />
<MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig newslot virtual instance bool ProcessCmdKey(valuetype System.Windows.Forms.Message& msg, valuetype System.Windows.Forms.Keys keyData, class System.Windows.Forms.Control control) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.ProcessCmdKey(System.Windows.Forms.Message@,System.Windows.Forms.Keys,System.Windows.Forms.Control)" />
<MemberSignature Language="VB.NET" Value="Protected Friend Overridable Function ProcessCmdKey (ByRef msg As Message, keyData As Keys, control As Control) As Boolean" />
<MemberSignature Language="F#" Value="override this.ProcessCmdKey : Message * System.Windows.Forms.Keys * System.Windows.Forms.Control -> bool" Usage="contextMenu.ProcessCmdKey (msg, keyData, control)" />
<MemberSignature Language="C++ CLI" Value="protected public:
 virtual bool ProcessCmdKey(System::Windows::Forms::Message % msg, System::Windows::Forms::Keys keyData, System::Windows::Forms::Control ^ control);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Boolean</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="msg" Type="System.Windows.Forms.Message" RefType="ref" Index="0" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
<Parameter Name="keyData" Type="System.Windows.Forms.Keys" Index="1" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
<Parameter Name="control" Type="System.Windows.Forms.Control" Index="2" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
</Parameters>
<Docs>
<param name="msg">A <see cref="T:System.Windows.Forms.Message" />, passed by reference, that represents the window message to process.</param>
<param name="keyData">One of the <see cref="T:System.Windows.Forms.Keys" /> values that represents the key to process.</param>
<param name="control">The control to which the command key applies.</param>
<summary>Processes a command key.</summary>
<returns>
<see langword="true" /> if the character was processed by the control; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This method is called during message preprocessing to handle command keys. Command keys are keys that always take precedence over regular input keys. Examples of command keys include accelerators and menu shortcuts. The method must return `true` to indicate that it has processed the command key, or `false` to indicate that the key is not a command key. This method is only called when the control is hosted in a Windows Forms application or as an ActiveX control.
The <xref:System.Windows.Forms.ContextMenu.ProcessCmdKey%2A> method first determines whether the control has a <xref:System.Windows.Forms.ContextMenu>, and if so, enables the <xref:System.Windows.Forms.ContextMenu> to process the command key. If the command key is not a menu shortcut and the control has a parent, the key is passed to the parent's <xref:System.Windows.Forms.ContextMenu.ProcessCmdKey%2A> method. The net effect is that command keys are "bubbled" up the control hierarchy. In addition to the key the user pressed, the key data also indicates which, if any, modifier keys were pressed at the same time as the key. Modifier keys include the SHIFT, CTRL, and ALT keys.
]]></format>
</remarks>
<block subset="none" type="overrides">
<para>When overriding the <see cref="M:System.Windows.Forms.Control.ProcessCmdKey(System.Windows.Forms.Message@,System.Windows.Forms.Keys)" /> method in a derived class, a control should return <see langword="true" /> to indicate that it has processed the key. For keys that are not processed by the control, the result of calling the base class's <see cref="M:System.Windows.Forms.Control.ProcessCmdKey(System.Windows.Forms.Message@,System.Windows.Forms.Keys)" /> method should be returned. Controls will seldom, if ever, need to override this method.</para>
</block>
</Docs>
</Member>
<Member MemberName="RightToLeft">
<MemberSignature Language="C#" Value="public virtual System.Windows.Forms.RightToLeft RightToLeft { get; set; }" />
<MemberSignature Language="ILAsm" Value=".property instance valuetype System.Windows.Forms.RightToLeft RightToLeft" />
<MemberSignature Language="DocId" Value="P:System.Windows.Forms.ContextMenu.RightToLeft" />
<MemberSignature Language="VB.NET" Value="Public Overridable Property RightToLeft As RightToLeft" />
<MemberSignature Language="F#" Value="member this.RightToLeft : System.Windows.Forms.RightToLeft with get, set" Usage="System.Windows.Forms.ContextMenu.RightToLeft" />
<MemberSignature Language="C++ CLI" Value="public:
 virtual property System::Windows::Forms::RightToLeft RightToLeft { System::Windows::Forms::RightToLeft get(); void set(System::Windows::Forms::RightToLeft value); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.Localizable(true)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.Localizable(true)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;netframework-4.8.1;windowsdesktop-10.0;windowsdesktop-3.0">
<AttributeName Language="C#">[System.ComponentModel.DefaultValue(System.Windows.Forms.RightToLeft.No)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DefaultValue(System.Windows.Forms.RightToLeft.No)>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Windows.Forms.RightToLeft</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets or sets a value indicating whether text displayed by the control is displayed from right to left.</summary>
<value>One of the <see cref="T:System.Windows.Forms.RightToLeft" /> values.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property enables your menus to support languages that are written from right to left. When this property is set to `RightToLeft.Yes`, the menu item text is displayed from right to left instead of the default left to right method.
> [!NOTE]
> For more information about how enabling right-to-left alignment affects Windows Forms controls, see the <xref:System.Windows.Forms.Control.RightToLeft%2A> property.
]]></format>
</remarks>
<exception cref="T:System.ComponentModel.InvalidEnumArgumentException">The value assigned to the property is not a valid member of the <see cref="T:System.Windows.Forms.RightToLeft" /> enumeration.</exception>
</Docs>
</Member>
<MemberGroup MemberName="Show">
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Docs>
<summary>Displays the shortcut menu at the specified position.</summary>
</Docs>
</MemberGroup>
<Member MemberName="Show">
<MemberSignature Language="C#" Value="public void Show (System.Windows.Forms.Control control, System.Drawing.Point pos);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Show(class System.Windows.Forms.Control control, valuetype System.Drawing.Point pos) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.Show(System.Windows.Forms.Control,System.Drawing.Point)" />
<MemberSignature Language="VB.NET" Value="Public Sub Show (control As Control, pos As Point)" />
<MemberSignature Language="F#" Value="member this.Show : System.Windows.Forms.Control * System.Drawing.Point -> unit" Usage="contextMenu.Show (control, pos)" />
<MemberSignature Language="C++ CLI" Value="public:
 void Show(System::Windows::Forms::Control ^ control, System::Drawing::Point pos);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="control" Type="System.Windows.Forms.Control" />
<Parameter Name="pos" Type="System.Drawing.Point" />
</Parameters>
<Docs>
<param name="control">A <see cref="T:System.Windows.Forms.Control" /> that specifies the control with which this shortcut menu is associated.</param>
<param name="pos">A <see cref="T:System.Drawing.Point" /> that specifies the coordinates at which to display the menu. These coordinates are specified relative to the client coordinates of the control specified in the <paramref name="control" /> parameter.</param>
<summary>Displays the shortcut menu at the specified position.</summary>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
Typically, a <xref:System.Windows.Forms.ContextMenu> is displayed when the user clicks the right mouse button on a control or area of the form that the <xref:System.Windows.Forms.ContextMenu> is bound to. You can use this method to manually display the shortcut menu at a specific location and bind it with a specific control. This method does not return until the menu is dismissed.
## Examples
The following code example demonstrates constructing a shortcut menu and using the <xref:System.Windows.Forms.ContextMenu.Show%2A> method. To run the example, paste the following code in a form containing a button named Button1. Ensure all events are associated with their event-handling methods.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/System.Windows.Forms.ManualContextMenu/CPP/form1.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenu/.ctor/form1.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/System.Windows.Forms.ManualContextMenu/VB/form1.vb" id="Snippet1":::
]]></format>
</remarks>
<exception cref="T:System.ArgumentNullException">The <paramref name="control" /> parameter is <see langword="null" />.</exception>
<exception cref="T:System.ArgumentException">The handle of the control does not exist or the control is not visible.</exception>
</Docs>
</Member>
<Member MemberName="Show">
<MemberSignature Language="C#" Value="public void Show (System.Windows.Forms.Control control, System.Drawing.Point pos, System.Windows.Forms.LeftRightAlignment alignment);" />
<MemberSignature Language="ILAsm" Value=".method public hidebysig instance void Show(class System.Windows.Forms.Control control, valuetype System.Drawing.Point pos, valuetype System.Windows.Forms.LeftRightAlignment alignment) cil managed" />
<MemberSignature Language="DocId" Value="M:System.Windows.Forms.ContextMenu.Show(System.Windows.Forms.Control,System.Drawing.Point,System.Windows.Forms.LeftRightAlignment)" />
<MemberSignature Language="VB.NET" Value="Public Sub Show (control As Control, pos As Point, alignment As LeftRightAlignment)" />
<MemberSignature Language="F#" Value="member this.Show : System.Windows.Forms.Control * System.Drawing.Point * System.Windows.Forms.LeftRightAlignment -> unit" Usage="contextMenu.Show (control, pos, alignment)" />
<MemberSignature Language="C++ CLI" Value="public:
 void Show(System::Windows::Forms::Control ^ control, System::Drawing::Point pos, System::Windows::Forms::LeftRightAlignment alignment);" />
<MemberType>Method</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<ReturnValue>
<ReturnType>System.Void</ReturnType>
</ReturnValue>
<Parameters>
<Parameter Name="control" Type="System.Windows.Forms.Control" Index="0" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
<Parameter Name="pos" Type="System.Drawing.Point" Index="1" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
<Parameter Name="alignment" Type="System.Windows.Forms.LeftRightAlignment" Index="2" FrameworkAlternate="netcore-3.0;netframework-2.0;netframework-3.0;netframework-3.5;netframework-4.0;netframework-4.5;netframework-4.5.1;netframework-4.5.2;netframework-4.6;netframework-4.6.1;netframework-4.6.2;netframework-4.7;netframework-4.7.1;netframework-4.7.2;netframework-4.8;windowsdesktop-3.0;netframework-4.8.1;windowsdesktop-10.0" />
</Parameters>
<Docs>
<param name="control">A <see cref="T:System.Windows.Forms.Control" /> that specifies the control with which this shortcut menu is associated.</param>
<param name="pos">A <see cref="T:System.Drawing.Point" /> that specifies the coordinates at which to display the menu. These coordinates are specified relative to the client coordinates of the control specified in the <paramref name="control" /> parameter.</param>
<param name="alignment">A <see cref="T:System.Windows.Forms.LeftRightAlignment" /> that specifies the alignment of the control relative to the <paramref name="pos" /> parameter.</param>
<summary>Displays the shortcut menu at the specified position and with the specified alignment.</summary>
<remarks>To be added.</remarks>
</Docs>
</Member>
<Member MemberName="SourceControl">
<MemberSignature Language="C#" Value="public System.Windows.Forms.Control SourceControl { get; }" />
<MemberSignature Language="ILAsm" Value=".property instance class System.Windows.Forms.Control SourceControl" />
<MemberSignature Language="DocId" Value="P:System.Windows.Forms.ContextMenu.SourceControl" />
<MemberSignature Language="VB.NET" Value="Public ReadOnly Property SourceControl As Control" />
<MemberSignature Language="F#" Value="member this.SourceControl : System.Windows.Forms.Control" Usage="System.Windows.Forms.ContextMenu.SourceControl" />
<MemberSignature Language="C++ CLI" Value="public:
 property System::Windows::Forms::Control ^ SourceControl { System::Windows::Forms::Control ^ get(); };" />
<MemberType>Property</MemberType>
<AssemblyInfo>
<AssemblyName>System.Windows.Forms</AssemblyName>
<AssemblyVersion>1.0.5000.0</AssemblyVersion>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
<AssemblyVersion>10.0.0.0</AssemblyVersion>
</AssemblyInfo>
<Attributes>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.Browsable(false)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.Browsable(false)>]</AttributeName>
</Attribute>
<Attribute>
<AttributeName Language="C#">[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]</AttributeName>
<AttributeName Language="F#">[<System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)>]</AttributeName>
</Attribute>
<Attribute FrameworkAlternate="netframework-4.0">
<AttributeName Language="C#">[get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]</AttributeName>
<AttributeName Language="F#">[<get: System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]</AttributeName>
</Attribute>
</Attributes>
<ReturnValue>
<ReturnType>System.Windows.Forms.Control</ReturnType>
</ReturnValue>
<Docs>
<summary>Gets the control that is displaying the shortcut menu.</summary>
<value>A <see cref="T:System.Windows.Forms.Control" /> that represents the control that is displaying the shortcut menu. If no control has displayed the shortcut menu, the property returns <see langword="null" />.</value>
<remarks>
<format type="text/markdown"><![CDATA[
## Remarks
This property enables you to determine which control currently displays the shortcut menu defined in the <xref:System.Windows.Forms.ContextMenu>. If the shortcut menu is not currently displayed, you can use this property to determine which control last displayed the shortcut menu. You can use this property in the <xref:System.Windows.Forms.ContextMenu.Popup> event to ensure that the control displays the proper menu items. You can also use this property to pass a reference to the control to a method that performs the tasks associated with a menu command displayed in the shortcut menu. Since the <xref:System.Windows.Forms.Form> class inherits from <xref:System.Windows.Forms.Control>, you can also use this property if the <xref:System.Windows.Forms.ContextMenu> is associated with a form.
## Examples
The following code example creates an event handler for the <xref:System.Windows.Forms.ContextMenu.Popup> event of the <xref:System.Windows.Forms.ContextMenu>. The code in the event handler determines which of two controls a <xref:System.Windows.Forms.PictureBox> named `pictureBox1` and a <xref:System.Windows.Forms.TextBox> named `textBox1` is the control displaying the shortcut menu. Depending on which control caused the <xref:System.Windows.Forms.ContextMenu> to display its shortcut menu, the control adds the appropriate <xref:System.Windows.Forms.MenuItem> objects to the <xref:System.Windows.Forms.ContextMenu>. This example requires that you have an instance of the <xref:System.Windows.Forms.ContextMenu> class, named `contextMenu1`, defined within the form. This example also requires that you have a <xref:System.Windows.Forms.TextBox> and <xref:System.Windows.Forms.PictureBox> added to a form and that the <xref:System.Windows.Forms.Control.ContextMenu%2A> property of these controls is set to `contextMenu1`.
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Winforms/Classic ContextMenu Example/CPP/source.cpp" id="Snippet1":::
:::code language="csharp" source="~/snippets/csharp/System.Windows.Forms/ContextMenu/Overview/source.cs" id="Snippet1":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Winforms/Classic ContextMenu Example/VB/source.vb" id="Snippet1":::
]]></format>
</remarks>
</Docs>
</Member>
</Members>
</Type>