AutoDEV Posted March 23, 2024 Posted March 23, 2024 (edited) Hello, im searching how make a default choice on TABLIST. Dim $msg, $ret, $listbox, $button, $i GUICreate("ListBox Selected Items Indices Demo", 400, 250, -1, -1) $listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL)) GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|") $button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button $ret = _GUICtrlListGetSelItems ($listbox) If (Not IsArray($ret)) Then MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItems") Else For $i = 1 To $ret[0] MsgBox(0, "Selected", $ret[$i]) Next EndIf EndSelect WEnd I have this code, i have found on forum. Please help me Edited March 24, 2024 by AutoDEV
Andreik Posted March 23, 2024 Posted March 23, 2024 Your last 10 threads contains scripts that doesn't even run. It looks like you are not here to learn anything. Your header files are missing, you use undefined functions, etc... SOLVE-SMART, Musashi and argumentum 3
Musashi Posted March 23, 2024 Posted March 23, 2024 5 hours ago, AutoDEV said: I have this code, i have found on forum. Please help me As always, the code snippet you posted is not runnable . Here is a revised version. What this has to do with TABLIST, however, is not clear to me. #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Global $msg, $ret, $listbox, $button, $i GUICreate("ListBox Selected Items Indices Demo", 400, 250, -1, -1) $listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL)) GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|") $button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button ;~ $ret = _GUICtrlListGetSelItems ($listbox) $ret = _GUICtrlListBox_GetSelItems ($listbox) If (Not IsArray($ret)) Then MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItems") Else For $i = 1 To $ret[0] MsgBox(0, "Selected", $ret[$i]) Next EndIf EndSelect WEnd "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."
AutoDEV Posted March 23, 2024 Author Posted March 23, 2024 (edited) Hello. I have one liste view. If i take this code : #include <GUIConstantsEx.au3> #include <ListBoxConstants.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Global $msg, $ret, $listbox, $button, $i GUICreate("ListBox Selected Items Indices Demo", 400, 250, -1, -1) $listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY, $LBS_MULTIPLESEL)) GUICtrlSetData($listbox, "test1|more testing|even more testing|demo|") $button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button ;~ $ret = _GUICtrlListGetSelItems ($listbox) $ret = _GUICtrlListBox_GetSelItems ($listbox) If (Not IsArray($ret)) Then MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItems") Else For $i = 1 To $ret[0] MsgBox(0, "Selected", $ret[$i]) Next EndIf EndSelect WEnd i show a list item but for exmeple : How to select more testing by defaul without i must click on. Is hard to understand i know and im sorry Edited March 23, 2024 by AutoDEV
Andreik Posted March 23, 2024 Posted March 23, 2024 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListBox.au3> Global $msg, $ret, $listbox, $button, $i GUICreate("ListBox Selected Items Indices Demo", 400, 250, -1, -1) $listbox = GUICtrlCreateList("", 125, 40, 180, 120, BitOR($LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY)) GUICtrlSetData($listbox, "test1|more testing|even more testing|demo", 'more testing') $button = GUICtrlCreateButton("Get Selected", 150, 160, 120, 40) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button ;~ $ret = _GUICtrlListGetSelItems ($listbox) $ret = _GUICtrlListBox_GetSelItems ($listbox) If (Not IsArray($ret)) Then MsgBox(16, "Error", "Unknown error from _GUICtrlListGetSelItems") Else For $i = 1 To $ret[0] MsgBox(0, "Selected", $ret[$i]) Next EndIf EndSelect WEnd Just read the documentation.
AutoDEV Posted March 24, 2024 Author Posted March 24, 2024 (edited) Big thx. Is 100% ok. Problem solved Just idk why but your work working if i edit by this else sorting data not working. If u can say why im happy $listMenu = GUICtrlCreateList("", 302, 67, 225, 126, BitXOR($GUI_SS_DEFAULT_LIST, $LBS_SORT, $WS_BORDER, $WS_VSCROLL, $LBS_NOTIFY)) GUICtrlSetData(-1, "--------------|Open Note|--------------", "Open Note") Edited March 24, 2024 by AutoDEV
Andreik Posted March 24, 2024 Posted March 24, 2024 If you don't use $LBS_MULTIPLESEL as style for your list it works to set default selection as 3rd parameter of GUICtrlSetData(), otherwise use _GUICtrlListBox_SetSel() to select the default value in the list.
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