private void BookmarkRemove(object sender, EventArgs e) { Bookmarks b = new Bookmarks(); b.DeleteBookmark((Bookmarks.BookmarkData)((MenuItem)sender).Tag); foreach (MenuItem mi in m_Bookmarks.MenuItems) { try { if (mi.Tag == ((MenuItem)sender).Parent.Tag) { m_Bookmarks.MenuItems.Remove(mi); } } catch { } } }
void AddBookmark(Bookmarks.BookmarkData bd) { MenuItem mi = new MenuItem(bd.Name); mi.Tag = bd; MenuItem Go = new MenuItem("Go", BookmarkGo); Go.Tag = bd.Path; MenuItem Remove = new MenuItem("Remove", BookmarkRemove); Remove.Tag = bd; mi.MenuItems.Add(Go); mi.MenuItems.Add(Remove); m_Bookmarks.MenuItems.Add(mi); }