tags:

views:

69

answers:

1

friends,where should i define FavoriteMenu to work this code? becouse it gives error:The name 'FavoritesMenu' does not exist in the current context

i solved above problem,i didnt define a contextMenuStrip for it.when i defined,that problem solved but now say The name 'MenuItems_Click' does not exist in the current context. should i named it anywhere in ContextMenuStrip?thanks

private void icnNotify_Click(object sender, EventArgs e)
    {

        // Create a new instance of the Favorites class 
        Favorite.Favorites objFavorites =
          new Favorite.Favorites();
        // Scan the Favorites folder 
        objFavorites.ScanFavorites();
        // Clear current menu items 
        FavoritesMenu.Items.Clear();
        // Process each objWebFavorite object  
        // in the Favorites collection 
        foreach (Favorite.WebFavorite objWebFavorite
           in objFavorites.FavoriteCollection)
        {
            // Declare a ToolStripMenuItem object 
            ToolStripMenuItem objMenuItem =
               new ToolStripMenuItem();
            // Set the properties of ToolStripMenuItem object
            objMenuItem.Text = objWebFavorite.Name;
            objMenuItem.Tag = objWebFavorite.Url;
            // Add a handler to Click event of new menu item 
            objMenuItem.Click +=
               new EventHandler(MenuItems_Click);
            // Add the ToolStripMenuItem object  
            // to the ContextMenu 
            FavoritesMenu.Items.Add(objMenuItem);
        }
private void MenuItems_Click(object sender,
  System.EventArgs e)
    {
        // Create a ToolStripMenuItem  
        // and fill it with sender parameter 
        ToolStripMenuItem s = (ToolStripMenuItem)sender;
        // Open the internet explorer to view selected  
        // favorite 
        System.Diagnostics.Process.Start(s.Tag.ToString());
    }
    private void ExitMenuItem_Click(object sender,
   System.EventArgs e)
    {
        Application.Exit();
    } 
A: 

use full access path otherwise state like (using namespace.class.components *name* =new namespace.class.components) ,refer msdn for using,because merely making an object doesnt give access to its internal member.

only after this type of definition, u can use name.X.Y etc.