I want to force the toolbarstyle but I can't get the "Office2013" to display when formloads.
Using SelectedIndex gets an error (
System.ArgumentOutOfRangeException occurredHResult=0x80131502Message=Index was out of range. Must be non-negative and less than the size of the collection.)
Code used:
Infragistics.Win.UltraWinToolbars.ComboBoxTool cb = new Infragistics.Win.UltraWinToolbars.ComboBoxTool("ComboBoxTool1");ultraToolbarsManager1.Style = ToolbarStyle.Office2013;cb.SelectedIndex =0;
Hello Felix,
Looking at your code, it appears that you are creating a new ComboBoxTool and attempting to set the SelectedIndex without adding any items to it's ValueList. As such, 0 is an invalid index. Here is a help article that demonstrates how to programmatically create a ComboBoxTool, add ValueListItems to it, and then add the control to the UltraToolbarsManager.
Let me know if you have any questions.
Chris
I tested your sample and I actually get same error too.
http://ko.infragistics.com/help/winforms/wintoolbarsmanager-add-a-combobox-tool-with-a-valuelist
// Add the tool to the toolbar's tools collection this.ultraToolbarsManager1.Toolbars[0].Tools.Add(comboboxtool);
System.ArgumentOutOfRangeException occurred HResult=0x80131502 Message=Index was out of range. Must be non-negative and less than the size of the collection. Source=mscorlib StackTrace: at System.Collections.ArrayList.get_Item(Int32 index) at Infragistics.Win.UltraWinToolbars.ToolbarsCollection.get_Item(Int32 index) at ToolbarTest.Form1..ctor() in c:\users\administrator\documents\visual studio 2017\Projects\ToolbarTest\ToolbarTest\Form1.cs:line 42 at ToolbarTest.Program.Main() in c:\users\administrator\documents\visual studio 2017\Projects\ToolbarTest\ToolbarTest\Program.cs:line 19
Ok, I finally figured out why this wasn't working. In the custom properties where I supplied the data list, the Data value didn't have "Office2013". I had to write in Office2013 then add the comboTool.Value = ToolbarStyle.Office2013 and now it works.
Thank you!
Felix
With the sample I wasn't able to get working. I am testing your latest one now and it does fire the Event. But it still doesn't force the word Offce2013 into the combobox display. I will keep working this and let you know.
Based on your reply, I'm not sure if you managed to get this working or are trying to get a reference to the ComboBoxTool so you can set the Value property. If you are trying to get the root tool, you can use code similar to:
ComboxBoxTool comboTool = (ComboxBoxTool)this.ultraToolbarsManager1.Tools["comboBoxTool1"];
comboTool.Value = ToolbarStyle.Office2013;
Ok, since I do not programmatically create my combobox and my value list is already added, I do I to my specific comboBox which has a key of "comboBoxTool1" so then I can add " // Assign the value to the root ComboBoxTool. This will trigger the ToolValueChanged event, and cause the Style of the UltraToolbarsManager to be set. comboboxtool.Value = ToolbarStyle.Office2013;"
Ok, yes your example is what I want to do. I'm going to try to see how to change my code to the "Office2013" to display.