Selected property
Returns or sets the selection state of items in a ListBox.
Syntax
object.Selected(index) [= Boolean ]
The Selected property syntax has these parts:
Part | Description |
---|---|
object | Required. A valid object. |
index | Required. An integer with a range from 0 to one less than the number of items in the list. |
Boolean | Optional. Whether an item is selected. |
Settings
The settings for Boolean are:
Value | Description |
---|---|
True | The item is selected. |
False | The item is not selected. |
Remarks
The Selected property is useful when users can make multiple selections. Use this property to determine the selected rows in a multi-select list box. You can also use this property to select or deselect rows in a list from code.
The default value of this property is based on the current selection state of the ListBox.
For single-selection list boxes, the Value or ListIndex properties are recommended for getting and setting the selection. In this case, ListIndex returns the index of the selected item. However, in a multiple selection, ListIndex returns the index of the row contained within the focus rectangle, regardless of whether the row is actually selected.
When a list box control's MultiSelect property is set to None, only one row can have its Selected property set to True.
Entering a value that is out of range for the index does not generate an error message, but does not set a property for any item in the list.
See also
Support and feedback
Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기