I've added a popup menutool on a ribbonbar and then added a button tool in that popup menu tool. The code generated by designer is:
Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool1 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("ViewFile");Infragistics.Win.UltraWinToolbars.PopupMenuTool popupMenuTool2 = new Infragistics.Win.UltraWinToolbars.PopupMenuTool("ViewFile");ribbonGroup1.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[ { popupMenuTool1 });Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool1 = new Infragistics.Win.UltraWinToolbars.ButtonTool("ButtonTool1");Infragistics.Win.UltraWinToolbars.ButtonTool buttonTool2 = new Infragistics.Win.UltraWinToolbars.ButtonTool("ButtonTool1");popupMenuTool2.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[ { buttonTool1 });buttonTool2.SharedProps.Caption = "ButtonTool1";this.ultraToolbarsManager1.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[ { popupMenuTool2, buttonTool2 });
It seems that designer is creating a copy of every tool placed on Ribbon. When i deleted the button tool the designer deleted the buttonTool1 but didnt delete the buttonTool2 which was a copy. Im used to adding and deleting controls in which case there will a lot of redundant code generated resulting in performance hit.
Why is that a separate copy of every tool being added on ribbon is created and on deletion the copy is actually not deleted from the code?
Thnks,
--Ayub
Thnks Mike.
Yes, it should work fine.
If i am not setting any instance properties i.e. im only setting caption for the tools then will the code posted by me in the previous reply work fine??
Thnks
This will work ok, but when you add the tool to the menu, it is actually cloned internally. If you had set any InstanceProps on the tool instance, they would actually be lost. If you do ever need to set any InstanceProps, use this code instead:
foreach(string str in filesList){ButtonTool _buttonTool = new ButtonTool(str);_buttonTool.SharedProps.Caption = str;ultraToolbarsManager1.Tools.Add(_buttonTool);ButtonTool _buttonToolInstance = (ButtonTool) ((PopupMenuTool) ultraToolbarsManager1.Tools["View File"]).Tools.AddTool(_buttonTool.Key);
_buttonToolInstance.InstanceProps.IsFirstInGroup = true;}
Hi Mike,
Thnks for the quick reply. I have to add tool items mostly buttons in popup menu on ribbon at runtime, I have tried the following code:
foreach(string str in filesList){
ButtonTool _buttonTool = new ButtonTool(str);_buttonTool.SharedProps.Caption = str;ultraToolbarsManager1.Tools.Add(_buttonTool);((PopupMenuTool) ultraToolbarsManager1.Tools["View File"]).Tools.Add(_buttonTool);
}
In the above code snippet im trying to add button tools on a popup menu with key "View File". Here i've made a single instance and used it in both toolbarmanager and popupmenu and it is working fine. But in the designer the same thing is achieved by making separate instances. Do you think the above code snippet is fine or kindly give suggestions in case of disagreement.