ContextMenu question...


Author
Message
StrataFrame Team
S
StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)StrataFrame Developer (4.2K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
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.
StarkMike
StarkMike
StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)
Group: Forum Members
Posts: 436, Visits: 944
With some help, I figured this out on my own and thought i would share the love Cool



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

StarkMike
StarkMike
StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)StrataFrame User (448 reputation)
Group: Forum Members
Posts: 436, Visits: 944
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
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search