Search the Community
Showing results for tags 'array listview'.
-
I am working on updates to a project I recently delivered to a customer, a front-end for Microsoft's SCCM tool. At present, a list of the Application collections they have is retrieved in a 2d array. One column of that array is then used to populate a combo box in the GUI (see screenshot). The customer would like to change the combo box to a List View, to give a more visual look to the GUI. I can do that, no problem, but am having problems with capturing the text of the highlighted item. I've used the $WM_NOTIFY function in the past for right-clicking on an item, but in this case, the customer would like a helpdesk tech to highlight the name of the collection and then click a button to add a machine to that collection. If I can capture the text of the item, I can query the array for the matching Collection.ID and perform the Add to Collection task no problem. I'm thinking _GUICtrlListView_GetItemText, but you seem to have to hard code the index number in there. Can anyone suggest how to go about capturing the text of the highlighted item? I added a short reproducer below. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <GuiListView.au3> Local $msg Local $aArray[5] $aArray[0] = "Adobe Acrobat Reader 9" $aArray[1] = "Adobe Flash Player 10.3" $aArray[2] = "CD AutoRun 1.0" $aArray[3] = "Core Utilities" $aArray[4] = "Dragon Naturally Speaking 10.0" GUICreate("Reproducer") $listview = GUICtrlCreateListView("listview items", 8, 80, 300, 300) $button = GUICtrlCreateButton("Add PC to collection", 280, 10, 110, 50) _GUICtrlListView_SetColumn($listview, 0, "", 300, 0) _GUICtrlListView_ClickItem($listview, 1, "right", False) For $i = 1 To UBound($aArray) - 1 GUICtrlCreateListViewItem($aArray[$i], $listview) Next GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button MsgBox(0, "", _GUICtrlListView_GetItemText($listview, 1));<---a way to detect the highlighted item. EndSelect WEnd GUIDelete()