Setting the SelectedIndex property results in the SelectedItem property being set to the item at that ordinal position in the Items collection.
Note: When the HasMRUList property is True, and the dropdown list contains MRU items, the SelectedIndex property represents the index of the item in the Items collection to which it corresponds, not the index in the dropdown list. Note: A setting of -1 has special meaning in that when the SelectedIndex property is set to -1, the current selection is cleared. In the case where the DropDownStyle property is set to DropDownList, this results in the control's Text property being cleared as well.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Add 8 items to the combo Me.UltraComboEditor1.Items.Add(1, "One") Me.UltraComboEditor1.Items.Add(2, "Two") Me.UltraComboEditor1.Items.Add(3, "Three") Me.UltraComboEditor1.Items.Add(4, "Four") Me.UltraComboEditor1.Items.Add(5, "Five") Me.UltraComboEditor1.Items.Add(6, "Six") Me.UltraComboEditor1.Items.Add(7, "Seven") Me.UltraComboEditor1.Items.Add(8, "Eight") ' This combo should always be in edit mode, Me.UltraComboEditor1.AlwaysInEditMode = True ' Turn on auto-complete for Internet Explorer type auto completion Me.UltraComboEditor1.AutoComplete = True ' Office XP look and feel. Me.UltraComboEditor1.DisplayStyle = Infragistics.Win.EmbeddableElementDisplayStyle.OfficeXP ' Assign a shared image and forecolor to each element. Me.UltraComboEditor1.ItemAppearance.Image = Me.Icon.ToBitmap() Me.UltraComboEditor1.ImageTransparentColor = Color.FromArgb(192, 192, 192) Me.UltraComboEditor1.ItemAppearance.ForeColor = Color.White ' Assign individual backColors to each element Dim baseColorIndex As Integer = 255 / Me.UltraComboEditor1.Items.Count Dim i As Integer For i = 0 To Me.UltraComboEditor1.Items.Count - 1 Me.UltraComboEditor1.Items(i).Appearance.BackColor = Color.FromArgb(100, 100, baseColorIndex + (baseColorIndex * i)) Next i Me.UltraComboEditor1.MaxDropDownItems = 6 Me.UltraComboEditor1.HasMRUList = True Me.UltraComboEditor1.SelectedIndex = 3 Me.UltraComboEditor1.SortStyle = Infragistics.Win.ValueListSortStyle.DescendingByValue End Sub
private void Form1_Load(object sender, System.EventArgs e) { // Add 8 items to the combo this.ultraComboEditor1.Items.Add(1,"One"); this.ultraComboEditor1.Items.Add(2,"Two"); this.ultraComboEditor1.Items.Add(3,"Three"); this.ultraComboEditor1.Items.Add(4,"Four"); this.ultraComboEditor1.Items.Add(5,"Five"); this.ultraComboEditor1.Items.Add(6,"Six"); this.ultraComboEditor1.Items.Add(7,"Seven"); this.ultraComboEditor1.Items.Add(8,"Eight"); // This combo should always be in edit mode, this.ultraComboEditor1.AlwaysInEditMode = true; // Turn on auto-complete for Internet Explorer type auto completion this.ultraComboEditor1.AutoComplete = true; // Office XP look and feel. this.ultraComboEditor1.DisplayStyle = Infragistics.Win.EmbeddableElementDisplayStyle.OfficeXP; // Assign a shared image and forecolor to each element. this.ultraComboEditor1.ItemAppearance.Image = this.Icon.ToBitmap(); this.ultraComboEditor1.ImageTransparentColor = Color.FromArgb(192,192,192); this.ultraComboEditor1.ItemAppearance.ForeColor = Color.White; // Assign individual backColors to each element int baseColorIndex = 255 / this.ultraComboEditor1.Items.Count; for(int i = 0; i < this.ultraComboEditor1.Items.Count; i++) { this.ultraComboEditor1.Items[i].Appearance.BackColor = Color.FromArgb(100,100,baseColorIndex + (baseColorIndex * i)); } this.ultraComboEditor1.MaxDropDownItems = 6; this.ultraComboEditor1.HasMRUList = true; this.ultraComboEditor1.SelectedIndex = 3; this.ultraComboEditor1.SortStyle = Infragistics.Win.ValueListSortStyle.DescendingByValue; }
Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2