SelectedIndexプロパティを設定すると、SelectedItem プロパティが、Items コレクションの対応する位置にある項目に設定されます。
注:HasMRUList プロパティが True で、ドロップダウンリストにMRU項目が含まれている場合、 SelectedIndex プロパティは、ドロップダウンリストのインデックスではなく、対応する Items コレクション内の項目のインデックスを表します。注:SelectedIndex プロパティを -1 に設定すると、現在の選択項目がクリアされます。DropDownStyle プロパティがDropDownListに設定されている場合は、このように設定すると Text プロパティも同様にクリアされます。
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; }