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 LiveListBox
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 dynamically, as well as updating a LiveLabel control.
Visual Basic | Copy Code |
---|
'In this example, items are added to a Live List control dynamically
'The items are simply reflections of when they were added
'When one of the items is selected, a LiveLabel is updated
'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 dynamically in code to a list control
'When the LiveButton is pressed, a new item is added to the list
LiveList1.Items.Add(DateTime.Now.ToString())
End Sub
Private Sub LiveList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LiveList1.SelectedIndexChanged
'A LiveLabel is updated whenever an item is selected from the list
LiveLabel1.Text = "This item was added at " + LiveList1.Items(LiveList1.SelectedIndex).ToString()
End Sub |
C# | Copy Code |
---|
//In this example, items are added to a Live List control dynamically
//The items are simply reflections of when they were added
//When one of the items is selected, a LiveLabel is updated
//LiveList1 could be a LiveListBox, LiveDropDownList, LiveRadioButtonList or LiveCheckBoxList
private void LiveButton1_Click(object sender, System.EventArgs e)
{
//Add items dynamically in code to a list control
//When the LiveButton is pressed, a new item is added to the list
LiveList1.Items.Add(DateTime.Now.ToString());
}
private void LiveList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
//A LiveLabel is updated whenever an item is selected from the list
LiveLabel1.Text = "This item was added at " + LiveList1.Items[LiveList1.SelectedIndex];
} |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0
See Also