By StarkMike - 3/1/2007
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.
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.
Thanks
|
By StarkMike - 3/2/2007
With some help, I figured this out on my own and thought i would share the love
FindActiveControl(Me.ActiveControl)
Private Function FindActiveControl(ByVal obj As Control) As Control
If TypeOf obj Is SplitContainer Then
obj = FindActiveControl(DirectCast(obj, SplitContainer).ActiveControl)
Else
Return obj
End If
Return obj
End Function
|
By StrataFrame Team - 3/2/2007
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.
|
|