We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Change bar items by code

Hello There, I used two XPMenu bars to display MainModule and SubModule menu items. I wrote following code to dynamically change the SubModule baritems when clicking on a MainModule item. In my code, I use ''barSubModule.Items.Clear();'' to clear old baritems. But it doesn''t work. The old baritems is still displaying with the new baritem appended behind them. I guess I need some kind refresh or so. Any idea? Thanks, Lan private void ResetSelectedModule(BarItem SelectedBarItem) { //get the selected submodule bar Bar barCurr = this.barHomeCategory; switch (SelectedBarItem.ID) { case "Home": barCurr = this.barHomeCategory; break; case "Sections": barCurr = barSectionCategory; break; case "Reports": barCurr = barReportCategory; break; case "Parameters": barCurr = barParameterCategory; break; case "Analysis": barCurr = barAnalysisCategory; break; case "Utility": barCurr =barUtilityCategory; break; } //clear old submodule items barSubModule.Items.Clear(); // add new submodule items for (int i=0;i
8 Replies

AD Administrator Syncfusion Team July 13, 2006 04:20 PM UTC

Hello There, I noticed this doesn''t work on MDI form. I attach a sample to you here. click File-->New, then click File-->Open, you can see it add up new baritems in without clear old ones. When you change the form to non-MDI form by changing the ISMDIForm property to false. It works. This is a urgent issue for me. Please help me get around it. Thanks. Lan >Hello There, >I used two XPMenu bars to display MainModule and SubModule menu items. I wrote following code to dynamically change the SubModule baritems when clicking on a MainModule item. In my code, I use >''barSubModule.Items.Clear();'' to clear old baritems. But it doesn''t work. The old baritems is still displaying with the new baritem appended behind them. I guess I need some kind refresh or so. >Any idea? >Thanks, >Lan > > private void ResetSelectedModule(BarItem SelectedBarItem) > { > > //get the selected submodule bar > Bar barCurr = this.barHomeCategory; > switch (SelectedBarItem.ID) > { > case "Home": > barCurr = this.barHomeCategory; > break; > case "Sections": > barCurr = barSectionCategory; > break; > case "Reports": > barCurr = barReportCategory; > break; > case "Parameters": > barCurr = barParameterCategory; > break; > case "Analysis": > barCurr = barAnalysisCategory; > break; > case "Utility": > barCurr =barUtilityCategory; > break; > } > //clear old submodule items > barSubModule.Items.Clear(); > // add new submodule items > for (int i=0;i { > barSubModule.Items.Add(barCurr.Items[i]); > } > > } >

Toolbar3.zip


MJ Mano J Syncfusion Team July 13, 2006 04:50 PM UTC

Hi Lan, When MainForm is a MDI Container, MergedBars are used instead of original Bars.This is because of Bars from different MdiChild forms can be merged to a single Bar. You should get the MergedEquivalent of the Bar (barModule) and clear the items as shown below private void barItem1_Click(object sender, System.EventArgs e) { //new-barFile Bar bar = this.mainFrameBarManager1.GetMergedEquivalent(barModule, barModule); bar.Items.Clear(); for (int i=0;i

AD Administrator Syncfusion Team July 13, 2006 05:13 PM UTC

Hello Mano, Thanks for quick reponse. You''ve sovled my problem. Have a great day! Lan >Hi Lan, > >When MainForm is a MDI Container, MergedBars are used instead of original Bars.This is because of Bars from different MdiChild forms can be merged to a single Bar. > >You should get the MergedEquivalent of the Bar (barModule) and clear the items as shown below > >private void barItem1_Click(object sender, System.EventArgs e) >{ > //new-barFile > Bar bar = this.mainFrameBarManager1.GetMergedEquivalent(barModule, barModule); > bar.Items.Clear(); > > for (int i=0;i { > barModule.Items.Add(barFile.Items[i]); > } >} > >I have attached a modified sample. Please refer to it and let me know if you have any questions. > >Thanks for using Syncfusion products. > >Regards, >Mano > >http://www.syncfusion.com/Support/user/uploads/Toolbar_13cc4e92.zip >


AD Administrator Syncfusion Team July 13, 2006 06:07 PM UTC

Hello Mano, One more question. when a MDI form uses XPMenu bar, set auto save/load customizations properties like this: mainFrameBarManager1.AutoLoadToolBarPositions=true; mainFrameBarManager1.AutoPersistCustomization=true; Where does Sysnfuction store the customized size/location etc? Does it store in windows registry? I''ve not done any code to save or load them. I guess Sysnfuction does it automatically. The reason is that I got a machine always load the old-version application''s setting. The old-ver application allows user change the size/position of XPMenu bar, now the new version has size and position fixed. The application always load the customized XPMenu bars'' size and position. I guess that I need to delete the old customized settings,say in registry, manually? Is it right? Lan


MJ Mano J Syncfusion Team July 13, 2006 06:44 PM UTC

Hi Lan, By default, Syncfusion XPMenus stores the Bar''s persisted state information into Isolated Storage folder (C:\Documents and Settings\\Local Settings\Application Data\IsolatedStorage\..). If you delete the files in this folder, it will restore the default settings. Please let me know if you have any questions. Regards, Mano


AD Administrator Syncfusion Team July 13, 2006 07:10 PM UTC

Hi Mano, In IsolatedStorage fold, there are a lot of subfolders. Does they all created by Syncfusion? Can I delete them all? Please see my attached folder image. Thanks, Lan >Hi Lan, > >By default, Syncfusion XPMenus stores the Bar''s persisted state information into Isolated Storage folder (C:\Documents and Settings\\Local Settings\Application Data\IsolatedStorage\..). > >If you delete the files in this folder, it will restore the default settings. > >Please let me know if you have any questions. > >Regards, >Mano

IsolatedStorage.zip


MJ Mano J Syncfusion Team July 13, 2006 07:48 PM UTC

Hi Lan, The persisted state information are stored in a binary file named ''SyncfusionToolsStateInfo.bin'' under the files folder (see attached screenshot). You can delete this BIN file to remove the persisted information. Regards, Mano snap_1.zip


AD Administrator Syncfusion Team July 13, 2006 08:42 PM UTC

Hi Mano, Thanks, It works now. Lan

Loader.
Live Chat Icon For mobile
Up arrow icon