Print Page | Close Window

How to delete menu item using parent

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=8791
Printed Date: 02 March 2025 at 3:38pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to delete menu item using parent
Posted By: sandy eggo
Subject: How to delete menu item using parent
Date Posted: 14 November 2007 at 5:27pm
I have an app that dynamically adds menu items based on the contents of a directory. Sub-Directories are added to the menu as sub-menu popups and files are added as menu items. My problem is that when the user elects to re-load the menu I have to remove all the dynamically added menu items without removing the compile-time menu items. So the problem is that I can't delete the empty menus after the sub items have been deleted. 
 
See the following code. The problem is the last line:
 

XtremeCommandBars.CommandBarControl foundMenuItem = null;

// check to see if the custom menu item exists in the FTM Commands menu

foundMenuItem = ControlMode.CommandBar.FindControl(

XTPControlType.xtpControlButton, IDNum, true, true );

if( foundMenuItem != null )

{

// get the parent menu of the found item for future check

XtremeCommandBars.CommandBar parentMenu =

(XtremeCommandBars.CommandBar)foundMenuItem.Parent;

// delete the item from the menu

foundMenuItem.Delete();

// delete the parent menu if there are no items left in it

if( parentMenu.Controls.Count <= 0 )

{

parentMenu.Delete(); // THIS DOESN'T WORK

}

 



-------------
sandy eggo



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net