<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="https://syndication.webwiz.net/rss_namespace/">
 <channel>
  <title>Codejock Developer Community : How to delete menu item using parent</title>
  <link>http://forum.codejock.com/</link>
  <description><![CDATA[This is an XML content feed of; Codejock Developer Community : Command Bars : How to delete menu item using parent]]></description>
  <copyright>Copyright (c) 2006-2013 Web Wiz Forums - All Rights Reserved.</copyright>
  <pubDate>Tue, 12 May 2026 21:03:42 +0000</pubDate>
  <lastBuildDate>Wed, 14 Nov 2007 17:27:54 +0000</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 12.04</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>forum.codejock.com/RSS_post_feed.asp?TID=8791</WebWizForums:feedURL>
  <image>
   <title><![CDATA[Codejock Developer Community]]></title>
   <url>http://forum.codejock.com/forum_images/codejock-logo.gif</url>
   <link>http://forum.codejock.com/</link>
  </image>
  <item>
   <title><![CDATA[How to delete menu item using parent : I have an app that dynamically...]]></title>
   <link>http://forum.codejock.com/forum_posts.asp?TID=8791&amp;PID=28479&amp;title=how-to-delete-menu-item-using-parent#28479</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://forum.codejock.com/member_profile.asp?PF=3493">sandy eggo</a><br /><strong>Subject:</strong> 8791<br /><strong>Posted:</strong> 14 November 2007 at 5:27pm<br /><br /><DIV>I have an app that dynamically adds menu items based on the contents of a directory.&nbsp;Sub-Directories are&nbsp;added to the menu as&nbsp;sub-menu popups and files are added as menu items. My problem is that when the user&nbsp;elects to re-load the menu I have to remove all the dynamically added&nbsp;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&nbsp;have been deleted.&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>See the following code. The problem is the last line: </DIV><DIV>&nbsp;</DIV><DIV><FONT size=2><P>XtremeCommandBars.CommandBarControl foundMenuItem = </FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2>;</P><P></FONT><FONT color=#008000 size=2>// check to see if the custom menu item exists in the FTM Commands menu</P><DIV></FONT><FONT size=2>foundMenuItem = ControlMode.CommandBar.FindControl( </DIV><P>XTPControlType.xtpControlButton, IDNum, </FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2>, </FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2> ); </P><P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>( foundMenuItem != </FONT><FONT color=#0000ff size=2>null</FONT><FONT size=2> )</P><P>{</P><P></FONT><FONT color=#008000 size=2>// get the parent menu of the found item for future check</P></FONT><FONT size=2><P>XtremeCommandBars.CommandBar parentMenu = </P><P>(XtremeCommandBars.CommandBar)foundMenuItem.Parent;</P><P></P><P></FONT><FONT color=#008000 size=2>// delete the item from the menu</P></FONT><FONT size=2><P>foundMenuItem.Delete();</P><P></FONT><FONT color=#008000 size=2>// delete the parent menu if there are no items left in it</P></FONT><FONT size=2><P></FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2>( parentMenu.Controls.Count &lt;= 0 )</P><P>{</P><P>parentMenu.Delete(); </FONT><FONT color=#008000 size=2>// THIS DOESN'T&nbsp;WORK</P></FONT><FONT size=2><P>}</P><P>&nbsp;</P></FONT></DIV>]]>
   </description>
   <pubDate>Wed, 14 Nov 2007 17:27:54 +0000</pubDate>
   <guid isPermaLink="true">http://forum.codejock.com/forum_posts.asp?TID=8791&amp;PID=28479&amp;title=how-to-delete-menu-item-using-parent#28479</guid>
  </item> 
 </channel>
</rss>