When adding a ButtonTool to a RibbonGroup using following code, the OwningRibbonGroup property stays null.
Am I doing something wrong?
See attached solution.
ps: By the way, I don't know if this is the right forum, but I find it really hard to find the right topic in the menu structure under Forums --> Windows Forums...
Anybody that could take a look at this one?
Hello ,
Thank you for the provided sample. I’ve added some code in ToolClik event of UltraToolbarsManager in order to check if OwningRibbonGroup is null and everything seems to be fine with your code. Please see the attached sample.
Please let me know if I am missing something.
Then why isn't it ok just after I added the ButtonTool to the RibbonGroup?
Kind regards, Lieven Cardoen
Had a look at the modified solution, and I can see indeed that at the moment of the click, the OwningRibbonGroup is set correctly.
However, after it has been added to the group, OwningRibbonGroup is null. It shouldn't just be ok after the Tool has been clicked... In my code, I need the RibbonGroup in Logic where the Tool hasn't been clicked.
Added two screenshots from my Visual Studio with debug information on the OwningRibbonGroup.
Kind regards, Lieven
In order to get WoningRibbonGroup you could use code like, just after you’ve added the tool to a group:
var ribbonTab = ultraToolbarsManager1.Ribbon.Tabs.Add("RibbonTab");
ribbonTab.Caption = "RibbonTab";
var ribbonGroup = ribbonTab.Groups.Add("RibbonGroup");
ribbonGroup.Caption = "RibbonGroup";
var buttonTool = new ButtonTool("ButtonTool");
buttonTool.SharedProps.Caption = "ButtonTool";
ultraToolbarsManager1.Tools.Add(buttonTool);
RibbonGroup rg = ribbonGroup.Tools.AddTool("ButtonTool").OwningRibbonGroup;
When you add the tool to the ribbon, a copy of the tool is created – this is the instance tool. The Add method returns you this tool object. This is the tool that exists on the ribbon, and so it has an owner. The global tool has no owner – it’s sort’ve a template.
Hello,
What's the difference with my original code? If I see it right, that's exactly the code that is not working...
Lieven
As far as I understand from your latest response you were able to solve your issue. Please let me know if you need my further assistance on this matter.
Thank you for using Infragistics Components.
Removed all the InsertToolForRibbonCustomization calls and replaced them with custom logic. OwningRibbonGroup issue is also gone now.
To be honest, I don' find the Infragistics API intuitive. Very often a developer is required to do things a certain kind of way to make it work. I am not supposed to know that behind the scenes Infragistics is working with some kind of template. In a lot of answers for instance I've heard that I first need to add the Tool to the ToolbarsManager collection...
Another problem for instance is that I use the InsertToolForRibbonCustomization. It is public but apparently it's not supposed to be used by developers like me... So why is it public then?
#abitfrustrated
I see the difference now, but it doesn't solve my problem. I'll get back to you.
By the way, I don't find this very intuitive...