rexx Posted August 27, 2009 Posted August 27, 2009 Is there a function works like _GUICtrlTreeView_SelectItem() but for listview? I got _GUICtrlListView_SetItemFocused() and _GUICtrlListView_SetItemSelected() to let an item selected and focused, but the listview is not auto scroll to the item. I know there's _GUICtrlListView_Scroll() but i don't know how much to scroll, set a big value can solve this but seems not a good solution. any suggestions? Thanks.
Authenticity Posted August 27, 2009 Posted August 27, 2009 #include <GUIConstantsEx.au3> #include <GUIListView.au3> Global $hGUI, $hListView Global $ListView $hGUI = GUICreate('Title', 400, 300) $ListView = GUICtrlCreateListView('1 |2 |3 |4 |5 |6 ', 0, 0, 400, 300) $hListView = GUICtrlGetHandle($ListView) _GUICtrlListView_BeginUpdate($hListView) For $i = 1 To 3000 GUICtrlCreateListViewItem('1 |2 |3 |4 |5 |6 ', $ListView) Next _GUICtrlListView_EndUpdate($hListView) AdlibEnable('_RandomlySelectLVItem', 1000) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE AdlibDisable() GUIDelete() Func _RandomlySelectLVItem() Local $iIndex = Random(0, _GUICtrlListView_GetItemCount($hListView)-1, 1) _GUICtrlListView_SetItemSelected($hListView, $iIndex, True, True) _SendMessage($hListView, $LVM_ENSUREVISIBLE, $iIndex, False) EndFunc
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now