SelectedIndex属性

适用范围
ListBox、ComboBox、Grid, TabControl

描述
获取或设置SelectedIndex属性返回当前选定项目的索引。

使用

GGet Form.Control.SelectedIndex, var  
GSet  Form.Control.SelectedIndex, value  
Form
指定窗体名称或含有窗体名称的字符串变量。
Control
指定控件名称或含有控件名称的字符串。控件必须位于指定窗体内。
var
取得属性值的整数变量。
value
在属性中设定的整数表达式。

数值
返回以0开始的选定项目索引。如果未选定项目,则会返回-1。

备注
使用SelectedIndex可确定用户在列表框或组合框中选定的项目。通常,会在控件的Click事件中完成。

另见
AddItem、ComboBox、List、ListBox、Grid

示例

Integer index  
GGet frmMain.lstParts.SelectedIndex, index