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...
Hello ,
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.
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
Then why isn't it ok just after I added the ButtonTool to the RibbonGroup?
Kind regards, Lieven Cardoen
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.
Anybody that could take a look at this one?