Gets or sets the lowest ordinal index of the selected items in the list.
Syntax
Visual Basic (Declaration) | |
---|
Public Overrides Property SelectedIndex As Integer |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As LiveCheckBoxList
Dim value As Integer
instance.SelectedIndex = value
value = instance.SelectedIndex |
C# | |
---|
public override int SelectedIndex {get; set;} |
C++/CLI | |
---|
public:
property int SelectedIndex {
int get() override;
void set ( int value) override;
} |
Example
The following example demonstrates adding items to a Live List control from a database, as well as updating a LiveImage control.
Visual Basic | Copy Code |
---|
'In this example, items are added to a Live List using Items.Add
'The items are sounds to be played, located in a "sounds" folder
'When one of the items is selected, the corresponding sound is played
'LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList
Private Sub LiveButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveButton1.Click
'Add items to the Live list control via the ListItemCollection
LiveList1.Items.Add("chord.wav")
LiveList1.Items.Add("chimes.wav")
LiveList1.Items.Add("exclamation.wav")
LiveList1.Items.Add("error.wav")
End Sub
Private Sub LiveList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveList1.SelectedIndexChanged
'When an item in the LiveList is selected or de-selected
'The selected sound that is topmost in the list will play
If (LiveList1.SelectedIndex > -1) Then
LiveSound1.Source = "sounds/" + LiveList1.Items(LiveList1.SelectedIndex).ToString()
LiveSound1.Play()
End If
End Sub |
C# | Copy Code |
---|
//In this example, items are added to a Live List using Items.Add
//The items are sounds to be played, located in a "sounds" folder
//When one of the items is selected, the corresponding sound is played
//LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList
private void LiveButton1_Click(object sender, System.EventArgs e)
{
//Add items to the Live List control via the ListItemCollection
LiveList1.Items.Add("chord.wav");
LiveList1.Items.Add("chimes.wav");
LiveList1.Items.Add("exclamation.wav");
LiveList1.Items.Add("error.wav");
}
private void LiveList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//When an item in the Live List is selected or de-selected
//The selected sound that is topmost in the list will play
if (LiveList1.SelectedIndex > -1)
{
LiveSound1.Source = "sounds/" + LiveList1.Items[LiveList1.SelectedIndex];
LiveSound1.Play();
}
} |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0
See Also