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.