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
So I have manually added the values through the ToolBar Manager. I was using the below code to grab the Value to change my toolbar style. I was also seeing what Index was being supplied as well. Below works so I thought I was on the right path to see how I can I change the SelectedIndex on a Form load. I am saving the "Office2013" in an .ini file so I can retrieve it so I can change the Combobox display to "Office2013". For now the combobox is blank on form load.
private void ultraToolbarsManager1_ToolValueChanged(object sender, ToolEventArgs e) { int test; ultraToolbarsManager1.Office2007UICompatibility = false; Infragistics.Win.UltraWinToolbars.ComboBoxTool cb = e.Tool as Infragistics.Win.UltraWinToolbars.ComboBoxTool; string _unit; _unit = cb.Value.ToString();
switch (_unit) { case "ValueListItem0": { ultraToolbarsManager1.Style = ToolbarStyle.Default; test = cb.SelectedIndex; } break;