The event handler receives an argument of type System.EventArgs containing data related to this event.
The SelectedIndexChanged is identical to the RepositoryItemComboBox.SelectedIndexChanged event available through the Properties group.
Refer to the RepositoryItemComboBox.SelectedIndexChanged topic for more information.
Note
This event fires only when the selected item changes. Although modifying the editor's item collection may also indirectly change the SelectedIndex property value (e.g., when you insert an item before the currently selected one), these modifications do not trigger the SelectedIndexChanged event.
Important
The SelectedIndexChanged does not fire when a previous and a currently selected items are equal objects.

Example
Consider a combo box editor displaying different font styles (regular, bold, italic, underline, strikeout). When you select an item from the dropdown list, a corresponding font style is applied to the combo box editor.
Combo box items in this example represent strings identifying names of specific font styles. In the SelectedIndexChanged event handler, we determine the currently selected item and convert it to a corresponding value of type System.Drawing.FontStyle. Then the new font is applied to the editor.
The following image shows a combo box editor when the Underline item is selected.

C# |
comboBoxEdit1.EditValue = "Regular";
comboBoxEdit1.Properties.Items.AddRange(new object[]
{"Bold", "Italic", "Regular", "StrikeOut", "Underline"});
comboBoxEdit1.SelectedIndexChanged += new System.EventHandler(
this.comboBoxEdit1_SelectedIndexChanged);
private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e) {
EnumConverter ec = TypeDescriptor.GetConverter(typeof(FontStyle)) as EnumConverter;
var cBox = sender as ComboBoxEdit;
if (cBox.SelectedIndex != -1) {
FontStyle selectedFontStyle = (FontStyle)ec.ConvertFrom(
cBox.Properties.Items[cBox.SelectedIndex]);
cBox.Properties.Appearance.Font =
new Font(cBox.Properties.Appearance.Font, selectedFontStyle);
}
}
|
VB |
ComboBoxEdit1.EditValue = "Regular"
ComboBoxEdit1.Properties.Items.AddRange(New Object() _
{"Bold", "Italic", "Regular", "StrikeOut", "Underline"})
Private Sub ComboBoxEdit1_SelectedIndexChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles ComboBoxEdit1.SelectedIndexChanged
Dim ec As EnumConverter = TryCast(TypeDescriptor.GetConverter(GetType(FontStyle)), EnumConverter)
Dim cBox = TryCast(sender, ComboBoxEdit)
If cBox.SelectedIndex <> -1 Then
Dim selectedFontStyle As FontStyle = CType(ec.ConvertFrom(cBox.Properties.Items(cBox.SelectedIndex)), FontStyle)
cBox.Properties.Appearance.Font = New Font(cBox.Properties.Appearance.Font, selectedFontStyle)
End If
End Sub
|