ComboBox.InSelection 屬性 (Access)ComboBox.InSelection property (Access)

您可以使用 InSelection 屬性來決定或指定是否已選取 [設計檢視中表單上的控制項。You can use the InSelection property to determine or specify whether a control on a form in Design view is selected. 可讀寫的 BooleanRead/write Boolean.

語法Syntax

運算式InSelectionexpression.InSelection

_運算式_代表**ComboBox** 物件的變數。expression A variable that represents a ComboBox object.

註解Remarks

選取控制項時,其調整控點可看見,且可調整大小。When a control is selected, its sizing handles are visible, and it can be resized by the user. 一次可選取一個以上的控制項。More than one control can be selected at a time.

範例Example

下列函數會使用 InSelection 屬性來判斷是否已選取表單上的 strControlName 控制項。The following function uses the InSelection property to determine whether the strControlName control on a form is selected.

若要測試此程式碼, IsControlSelected函式程式碼貼入 Northwind 範例資料庫中的程式碼模組的宣告區段中,開啟 [ Customers ] 表單在設計檢視中,然後選取 [ CompanyName控制項。To test this code, paste the IsControlSelected function code in the Declarations section of a code module in the Northwind sample database, open the Customers form in Design view, and select the CompanyName control. 在 [偵錯] 視窗中輸入下列這一行。Enter the following line in the Debug window.

? IsControlSelected (Forms!Customers, "CompanyName") 
 
Function IsControlSelected(frm As Form, _ 
 strControlName As String) As Boolean 
 Dim intI As Integer, ctl As Control 
 If frm.CurrentView <> 0 Then 
 ' Form is not in Design view. 
 Exit Function 
 Else 
 For intI = 0 To frm.Count - 1 
 Set ctl = frm(intI) 
 If ctl.InSelection = True Then 
 ' Is desired control selected? 
 If UCase(ctl.Name) = UCase(strControlName) Then 
 IsControlSelected = True 
 Exit Function 
 End If 
 Else 
 IsControlSelected = False 
 End If 
 Next intI 
 End If 
End Function

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.