Hi, with the following Code i add a Buttontool to my WinToolbars On the Popupmenu File i have already some entries. When i add now Print it appears in the Menu on the last position.How can i change the order that it appear for example on the first position
i have at the moment File>Save>save as>exit>print
i want haveFile>Print >Save>save as>exit
Dim popupMenuToolDatei As Infragistics.Win.UltraWinToolbars.PopupMenuToolpopupMenuToolDatei = Me.UltraToolbarsManager1.Tools("File")Dim menuButton1 As New Infragistics.Win.UltraWinToolbars.ButtonTool("Print")menuButton1.SharedProps.Caption = "Print"Me.UltraToolbarsManager1.Tools.AddRange(New ToolBase() {menuButton1})popupMenuToolDatei.Tools.AddTool("Print")
Change the last line line to
popupMenuToolDatei.Tools.InsertTool(0, "Print")
The order of the tools in the collection is the order they will appear in the menu. This will insert the tool at the first location in the collection and therefore the first location in the menu.
Hi Mike,
I was reading about this but and tried to do the same as you suggested. I want to change the order for a new button so it can be the first one in the list. The code I have is this:
Infragistics.Win.UltraWinToolbars.ButtonTool custButton = new Infragistics.Win.UltraWinToolbars.ButtonTool("JobTravPrintCustom"); Infragistics.Win.UltraWinToolbars.PopupMenuTool pop = default(Infragistics.Win.UltraWinToolbars.PopupMenuTool); custButton.SharedProps.Caption = "Job Traveler";
ultraToolbarsManager.Tools.Add(custButton); pop = (Infragistics.Win.UltraWinToolbars.PopupMenuTool)ultraToolbarsManager.Tools["Print"]; pop.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {custButton}); pop.Tools.InsertTool(0, "JobTravPrintCustom");
The InsertTool work fine to set it in as first location but the problem is that the new option that I created is being duplicated (option 1 and 3 are same) when I see the menu. How can I solve this?
It is being displayed like this:
Print > Job Traveler
Production Detail
Job Traveler
Thanks
David
Hey David.
Taking a quick look at the code you provided, the reason the "Job Traveler" tool is duplicated in your PopupMenu is due to the AddRange() call.
This line of code adds the "Job Traveler" tool to the end of the menu:
pop.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[] {custButton});
And this line of code adds it at the beginning of the menu:
pop.Tools.InsertTool(0, "JobTravPrintCustom");
Simply remove the AddRange() call and you should be all set.
Let me know if you have any questions.
Chris