System.Windows.Forms.ContextMenu.SourceControl Property

Gets the control that is displaying the shortcut menu.

Syntax

[System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)]
[System.ComponentModel.Browsable(false)]
public Control SourceControl { get; }

Value

Documentation for this section has not yet been entered.

Remarks

This property enables you to determine which control currently displays the shortcut menu defined in the 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 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 System.Windows.Forms.Form class inherits from System.Windows.Forms.Control, you can also use this property if the System.Windows.Forms.ContextMenu is associated with a form.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0