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)

public:
[BrowsableAttribute(false)]
property Control^ SourceControl {
	[UIPermissionAttribute(SecurityAction::Demand, Window = UIPermissionWindow::AllWindows)]
	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.

UIPermission

for all windows to set this property value. Associated enumeration: UIPermissionWindow::AllWindows

.NET Framework
Available since 2.0
Return to top
Show: