﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » .NET Forums » General .NET Discussion  » ContextMenu question...</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 01:34:10 GMT</lastBuildDate><ttl>20</ttl><item><title>ContextMenu question...</title><link>http://forum.strataframe.net/FindPost7253.aspx</link><description>I have two listviews and both of them are associated with the same contextmenu. When the user clicks the 'select all' menu item in the contextmenu the click event of the menu item calls me.activecontrol so I know which listview was clicked on. This worked fine until I put the listviews into the split container.&lt;br&gt;
&lt;br&gt;
Any suggestions on how I can fix this? I was trying to avoid having duplicates of the same contextmenu on my form for each listview.&lt;br&gt;
&lt;br&gt;
Thanks</description><pubDate>Fri, 02 Mar 2007 09:05:48 GMT</pubDate><dc:creator>StarkMike</dc:creator></item><item><title>RE: ContextMenu question...</title><link>http://forum.strataframe.net/FindPost7266.aspx</link><description>Yes, that will certainly work... If you need to nest those calls (say you have the listview in a panel), you can call it recursively... ActiveControl is a property of ContainerControl (not just the split container), so, if you find that the ActiveControl is nothing, then you can probably cycle through the controls collection of the container and check the ActiveControl property of any of the container controls within it.</description><pubDate>Fri, 02 Mar 2007 09:05:48 GMT</pubDate><dc:creator>StrataFrame Team</dc:creator></item><item><title>RE: ContextMenu question...</title><link>http://forum.strataframe.net/FindPost7261.aspx</link><description>With some help, I figured this out on my own and thought i would share the love :cool:&lt;br&gt;
&lt;br&gt;
    FindActiveControl(Me.ActiveControl)&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
    Private Function FindActiveControl(ByVal obj As Control) As Control&lt;br&gt;
        If TypeOf obj Is SplitContainer Then&lt;br&gt;
            obj = FindActiveControl(DirectCast(obj, SplitContainer).ActiveControl)&lt;br&gt;
        Else&lt;br&gt;
            Return obj&lt;br&gt;
        End If&lt;br&gt;
&lt;br&gt;
        Return obj&lt;br&gt;
    End Function&lt;br&gt;</description><pubDate>Fri, 02 Mar 2007 08:54:59 GMT</pubDate><dc:creator>StarkMike</dc:creator></item></channel></rss>