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
The sample code in the help article assumes that there is already at least one toolbar created within the UltraToolbarsManager. You're received the ArgumentOutOfRange exception due to not having a toolbar to add the ComboBoxTool to.
I'm not sure how you are getting from the .ini file to the assigning of the ToolbarStyle, but my assumption is that you are not setting the Value property on the ComboBoxTool. As such, the ToolValueChanged event is not firing and the ComboBoxTool is still blank when the form loads.
I've attached a sample that demonstrates how to populate a ComboBoxTool with the ToolbarStyle, handle to ToolValueChanged event, and set the initial value of the ComboBoxTool.
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;"
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, 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