Loc Posted June 26, 2021 Posted June 26, 2021 I am looking to compare item on 2 listviews. Includes: Lv1 and Lv2 Left click on the item in Lv1 and _GUICtrlListview_Selected() on the item in Lv2 when the item is the same. The items here can't be ordered, it's just that the items can be the same
Moderators Melba23 Posted June 26, 2021 Moderators Posted June 26, 2021 MrRow, And what have you tried that has not worked? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Loc Posted June 27, 2021 Author Posted June 27, 2021 Since my code is too long, I made an example expandcollapse popup#include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <GuiListView.au3> #include <String.au3> #include <GuiComboBox.au3> #include <Array.au3> Local $GUI, $ListView1, $ListView2 $GUI = GUICreate("Test", 567, 441, 192, 124) GUICtrlCreateLabel("Listview 1", 8, 0, 72, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $ListView1 = GUICtrlCreateListView("String|int", 0, 32, 274, 406) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) _Listview_Additem('Ok') _Listview_Additem('Calcel') _Listview_Additem('Text') _Listview_Additem('Test') Local $hListView1 = GUICtrlGetHandle($ListView1) ;_______________________________________________________ GUICtrlCreateLabel("Listview 2", 296, 0, 72, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $ListView2 = GUICtrlCreateListView("int|String", 288, 32, 274, 406) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) _Listview_Additem('Text', 'LV2') _Listview_Additem('Ok', 'LV2') _Listview_Additem('Test', 'LV2') _Listview_Additem('Calcel', 'LV2') GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Listview_Additem($Setitem, $LVSet = 'LV1') $Rdint = StringFormat("%04d", Random(1000, 9999, 1)) If $LVSet = 'LV1' Then GUICtrlCreateListViewItem($Setitem & "|" & $Rdint, $ListView1) ElseIf $LVSet = 'LV2' Then GUICtrlCreateListViewItem($Rdint & "|" & $Setitem, $ListView2) EndIf EndFunc Func WM_NOTIFY($hWnd, $nMsg, $wParam, $lParam) Local $stNmhdr = DllStructCreate("dword;int;int", $lParam), $hWndFrom = DllStructGetData($stNmhdr, 1) Local $nNotifyCode = DllStructGetData($stNmhdr, 3) Local $hWndListView = $hListView1 Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK _LV_SetItemSelected() EndSwitch EndSwitch EndFunc Func _LV_SetItemSelected() Local $GetClmLV1 = _GUICtrlListView_GetSelectedColumn($ListView1) Local $GetSltLV1 = _GUICtrlListView_GetSelectedIndices($ListView1) Local $GetItLV1 = _GUICtrlListView_GetItemTextArray($ListView1,$GetClmLV1);Listview1 Local $GetClmLV2 = _GUICtrlListView_GetSelectedColumn($ListView2) Local $GetSltLV2 = _GUICtrlListView_GetSelectedIndices($ListView2) Local $GetItLV2 = _GUICtrlListView_GetItemTextArray($ListView2,$GetClmLV2);Listview2 $Search = $GetItLV1[0] = $GetItLV2[1] _GUICtrlListView_SetItemSelected($ListView2,$Search) _GUICtrlListView_EnsureVisible($ListView2, $Search) EndFunc ;$Search = _GUICtrlListView_FindText($ListView1, $GetIt, $Search) ;_GUICtrlListView_SetItemSelected($ListView1,$Search) ;_GUICtrlListView_EnsureVisible($ListView1, $Search)
Moderators Melba23 Posted June 27, 2021 Moderators Posted June 27, 2021 MrRow, How about this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> $GUI = GUICreate("Test", 567, 441, 192, 124) GUICtrlCreateLabel("Listview 1", 8, 0, 72, 24) $ListView1 = GUICtrlCreateListView("String|int", 0, 32, 274, 406) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) _Listview_Additem('Ok') _Listview_Additem('Cancel') _Listview_Additem('Text') _Listview_Additem('Test') $hListView1 = GUICtrlGetHandle($ListView1) GUICtrlCreateLabel("Listview 2", 296, 0, 72, 24) $ListView2 = GUICtrlCreateListView("int|String", 288, 32, 274, 406) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 100) $hListView2 = GUICtrlGetHandle($ListView2) _Listview_Additem('Text', 'LV2') _Listview_Additem('Ok', 'LV2') _Listview_Additem('Test', 'LV2') _Listview_Additem('Cancel', 'LV2') GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _Listview_Additem($Setitem, $LVSet = 'LV1') $Rdint = StringFormat("%04d", Random(1000, 9999, 1)) If $LVSet = 'LV1' Then GUICtrlCreateListViewItem($Setitem & "|" & $Rdint, $ListView1) ElseIf $LVSet = 'LV2' Then GUICtrlCreateListViewItem($Rdint & "|" & $Setitem, $ListView2) EndIf EndFunc Func WM_NOTIFY($hWnd, $nMsg, $wParam, $lParam) Local $stNmhdr = DllStructCreate("dword;int;int", $lParam), $hWndFrom = DllStructGetData($stNmhdr, 1) Local $nNotifyCode = DllStructGetData($stNmhdr, 3) Local $hWndListView = $hListView1 Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK _LV_SetItemSelected() EndSwitch EndSwitch EndFunc Func _LV_SetItemSelected() ; Determine item clicked in LV1 $iIndex = _GUICtrlListView_GetSelectedIndices($hListView1, False) $sText = _GUICtrlListView_GetItemText($hListView1, $iIndex) ; Find equivalent in LV2 $iIndex = _GUICtrlListView_FindInText($hListView2, $sText) ; Highlight item and ensure visible _GUICtrlListView_SetItemState($hListView2, $iIndex, $LVIS_SELECTED, $LVIS_SELECTED) _GUICtrlListView_EnsureVisible($hListView2, $iIndex) _WinAPI_SetFocus($hListView2) EndFunc M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
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