Creating Menus on the fly
Hi all
I'm a little stuck trying to convert some code to c# from vb. The code is supposed to allow me to do something different for each menu item however the menuitems are created on the fly. It is a favorites menu for a web browser. These are the two segments of VB code that are giving me trouble
favoritesMenu = New MenuItem("&Favorites", New System.EventHandler(AddressOf Me.MenuSelect))
creates my menu and code later on creates items to go in it. When i click on a menu item that has been added it executes
Private Sub MenuSelect(ByVal sender As Object, ByVal e As System.EventArgs)
If ((sender.Parent.text = "&Favorites"") And (sender.text <> "&Add To Favorites")) Then
It is this sender.parent part that's killing me. It finds that i have juct clicked on something in the Favorites menu that is not the "add to favorites" item. This means it is a favorite. Ok....so my ploblem is...in C# you can't have sender.parent.
An ideas how i can work around this?