# C1.Win.Command.C1ContextMenu.SourceControl

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Win_Command_C1ContextMenu_SourceControl_" data-uid="C1.Win.Command.C1ContextMenu.SourceControl*">SourceControl Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Win_Command_C1ContextMenu_SourceControl_" data-uid="C1.Win.Command.C1ContextMenu.SourceControl*"></a>
<h4 id="C1_Win_Command_C1ContextMenu_SourceControl" data-uid="C1.Win.Command.C1ContextMenu.SourceControl">SourceControl</h4>
<div class="markdown level1 summary"><p>Gets the control that is displaying the shortcut menu.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">[Browsable(false)]
public Control SourceControl { get; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">&lt;Browsable(False)&gt;
Public ReadOnly Property SourceControl As Control</code></pre>
</div>
<h5 id="C1_Win_Command_C1ContextMenu_SourceControl_remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This property enables you to determine which control currently displays the shortcut menu defined in the <a class="xref" href="C1.Win.Command.C1ContextMenu.html">C1ContextMenu</a>.
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 <a class="xref" href="C1.Win.Command.C1CommandMenu.Popup.html">Popup</a> 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.</p>
</div>
<h5 id="C1_Win_Command_C1ContextMenu_SourceControl_examples">Examples</h5>
<p>The following code example creates an event handler for the <a class="xref" href="C1.Win.Command.C1CommandMenu.Popup.html">Popup</a> event of the <a class="xref" href="C1.Win.Command.C1ContextMenu.html">C1ContextMenu</a>. 
The code in the event handler determines which of two controls a PictureBox named pictureBox1 and a TextBox named textBox1 is the control 
displaying the shortcut menu. </p>
<p>Depending on which control caused the <a class="xref" href="C1.Win.Command.C1ContextMenu.html">C1ContextMenu</a> to display its shortcut menu, the control shows or hides the appropriate 
menu items of <a class="xref" href="C1.Win.Command.C1Command.html">C1Command</a>. </p>
<p>This example requires that you have an instance of the <a class="xref" href="C1.Win.Command.C1ContextMenu.html">C1ContextMenu</a> class, 
named c1ContextMenu1, defined within the form. c1ContextMenu should have "Copy", "Find", "Change Picture" menu items.
This example also requires that you have a TextBox and PictureBox added to a form and that the C1ContextMenu property of these controls is set to c1ContextMenu1.
</p>
<pre><code class="lang-csharp"> private void c1ContextMenu1_Popup(object sender, EventArgs e)
{
    Control c = c1ContextMenu1.SourceControl;
    // Copy and Find is dispayed for textBox1
    c1CommandCopy.Visible = (c == textBox1);
    c1CommandFind.Visible = (c == textBox1);
    // Change Picture is dispayed for pictureBox1
    c1CommandChangePicture.Visible = (c == pictureBox1);
}</code></pre>

</div>
