Hi,
I am trying to add buttons to a group in a tab using the following code and then set them to be large buttons that i can add an image to. I can't see any way to get this to work, does anyone have any ideas?
//create tools
ButtonTool _btnTest1 = new ButtonTool("Test1"); ;
ButtonTool _btnTest2 = new ButtonTool("Test2"); ;
ButtonTool _btnTest3 = new ButtonTool("Test3"); ;
_btnTest1.SharedProps.Caption = "TEST1";
_btnTest1.InstanceProps.MinimumSizeOnRibbon = RibbonToolSize.Large;
//_btnTest1.InstanceProps.AppearancesLarge.Appearance.Image = WindowsApplication5.Properties.Resources.LEA1;
_btnTest1.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large;
_btnTest2.SharedProps.Caption = "TEST2";
_btnTest2.InstanceProps.MinimumSizeOnRibbon = RibbonToolSize.Large;
//_btnTest2.InstanceProps.AppearancesLarge.Appearance.Image = WindowsApplication5.Properties.Resources.LEAHat;
_btnTest2.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large;
_btnTest3.SharedProps.Caption = "TEST3";
_btnTest3.InstanceProps.MinimumSizeOnRibbon = RibbonToolSize.Large;
//_btnTest3.InstanceProps.AppearancesLarge.Appearance.Image = WindowsApplication5.Properties.Resources.person1;
_btnTest3.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large;
//add tools to root collection
TBM_Test.Tools.AddRange(new Infragistics.Win.UltraWinToolbars.ToolBase[ { _btnTest1, _btnTest2, _btnTest3 });
//add tabs and groups to the ribbon
TBM_Test.Ribbon.CaptionAreaActiveAppearance.BackColor = System.Drawing.Color.DarkSeaGreen;
TBM_Test.Ribbon.Tabs.Add("Boundaries");
TBM_Test.Ribbon.Tabs["Boundaries"].Groups.Add("BoundaryGroup");
TBM_Test.Ribbon.Tabs.Add("Addresses");
TBM_Test.Ribbon.Tabs["Addresses"].Groups.Add("AddressesGroup");
//add tools to the tabs
TBM_Test.Ribbon.Tabs["Boundaries"].Groups["BoundaryGroup"].Tools.AddTool("Test1");
TBM_Test.Ribbon.Tabs["Addresses"].Groups["AddressesGroup"].Tools.AddTool("Test2");
TBM_Test.Ribbon.Tabs["Addresses"].Groups["AddressesGroup"].Tools.AddTool("Test3");
TBM_Test.UseLargeImagesOnToolbar = true;
TBM_Test.UseLargeImagesOnMenu = true;
Thanks
I'll answer this one myself - you need to set the preferred size at the group level
e.g TBM_Test.Ribbon.Tabs["Addresses"].Groups["AddressesGroup"].PreferredSizeOnRibbon = RibbonToolSize.Large;
Is this correct? Its a little confusing if so as its the items not the group that we are displaying large? Should it not be something like TBM_Test.Ribbon.Tabs["Addresses"].Groups["AddressesGroup"].Items.PreferredSizeOnRibbon = RibbonToolSize.Large;?
You are correct, the tools are displaying large, not the group. However, the PreferredSizeOnRibbon property is just a default for the tools it contains. You can also set this on individual tools like this:
ToolBase instanceTool = TBM_Test.Ribbon.Tabs["Addresses"].Groups["AddressesGroup"].Tools["Test1"];instanceTool.InstanceProps.MinimumSizeOnRibbon = RibbonToolSize.Large;instanceTool.InstanceProps.PreferredSizeOnRibbon = RibbonToolSize.Large;
The reason why your original code did not work is you were setting the InstanceProps of root tools. These settings are actually ignored because each instance of the root tool on a toolbar, menu, or ribbon group uses its own InstanceProps.
Hi.
I have a similar problem about button size. I'm using the Ribbon within an SCSF application and my buttons are being added via UIExtension sites.
I understand the difference between the instance of the button and the root tools button but I'm unsure how to get the instance of a button via the CAB UIExtensionSite - Is this possible?
I don't really want to access the Shell ToolbarManager directly (although that is easy enough) as I don't want my business modules to have such a detailed knowledge of the shells menu structure - I like and prefer the abstraction provided by UI extensions.
Apologies if the question is stupid but I'm new to CAB and even newer to Infragistics.
Cheers
Hello,
I believe that when a tool is added to the UIExtensionSite, it returns a reference to the actual instance tool that was created. So if you cast the object returned from the Add() call to a ToolBase, you should be able to accesss it's InstanceProps.
If this is not what you are looking for, please let me know.
Thanks,
Chris