Results 1 to 3 of 3

Thread: Creating Menus on the fly

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    35

    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?

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Try this
    Code:
    ((MenuItem)sender).Parent
    Dont gain the world and lose your soul

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2002
    Posts
    35
    ahh!! you're a ledgend....i can't believe i didn't think of that =)

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width