Export (0) Print
Expand All

ContextMenuStrip::SourceControl Property

Gets the last control that caused this ContextMenuStrip to be displayed.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public:
property Control^ SourceControl {
	Control^ get ();
}

Property Value

Type: System.Windows.Forms::Control
The control that caused this ContextMenuStrip to be displayed.

Common uses of the SourceControl property include the following:

  • Adding, removing, enabling, or disabling a menu item during the Opening event.

  • Deciding on modifications of a chosen command based on the control that last displayed the ContextMenuStrip.

The following code example demonstrates dynamic SourceControl determination with reuse, and handling of the Opening event. This example is part of a larger example provided for the ContextMenuStrip class.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Show:
© 2015 Microsoft