指定された文字列で始まるアイテムを検索します。
#Include <GuiListBox.au3>
_GUICtrlListBox_SelectString($hWnd, $sText[, $iIndex = -1])
パラメータ
$hWnd | コントロールのハンドル |
$sText | 検索文字列 |
$iIndex | [オプション]検索を開始アイテムの一つ前のアイテムのゼロ始まりのインデックスを指定します。 検索がリストボックスの末尾まで到達すると、リストボックスの先頭から$iIndexで指定されたアイテムまで検索が続行されます。 $iIndexが-1の場合、リストボックス全体が先頭から検索されます。 |
返し値
成功: | 選択されたアイテムのゼロ始まりのインデックス |
失敗: | -1 |
注意
必要な場合、選択アイテムが表示されるようにリストボックスはスクロールされます。
関連
_GUICtrlListBox_FindString, _GUICtrlListBox_FindInText
例
#AutoIt3Wrapper_au3check_parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GUIListBox.au3>
#include <GuiConstantsEx.au3>
Opt('MustDeclareVars', 1)
$Debug_LB = False ; ListBox関数に渡されるClassNameを調べる。動作を確認するにはTrueを設定し、他のコントロールのハンドルを使用
_Main()
Func _Main()
Local $sText, $hListBox
; GUIを作成
GUICreate("List Box Select String", 400, 296)
$hListBox = GUICtrlCreateList("", 2, 2, 396, 296)
GUISetState()
; 文字列を追加
_GUICtrlListBox_BeginUpdate($hListBox)
For $iI = 1 To 10
$sText = StringFormat("%03d : Random string ", Random(1, 100, 1))
For $iX = 1 To Random(1, 20, 1)
$sText &= Chr(Random(65, 90, 1))
Next
_GUICtrlListBox_AddString($hListBox, $sText)
Next
_GUICtrlListBox_AddString($hListBox, "020 : Target string")
_GUICtrlListBox_EndUpdate($hListBox)
; 文字列を選択
MsgBox(4160, "Information", "Target String Index: " & _GUICtrlListBox_SelectString($hListBox, "020 : T"));
; ユーザーが終了するまでループ
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main