Ace08 Posted October 29, 2010 Share Posted October 29, 2010 uhm guys i've used the following UDF code below to make my list view look like a spreadsheet(with cells) for $i = 1 to UBound($_Records) - 1 _GUICtrlListView_AddItem($hListView, $ID, $i - 1) _GUICtrlListView_AddSubItem($hListView, $i - 1, $LName, 1) _GUICtrlListView_AddSubItem($hListView, $i - 1, $FName, 1) next question is how do i get the values in the cell i picked? i've searched and found this _GUICtrlListView_GetItem($hListView, 1) but i can't seem to figure out how to use this to get the values of the cell i have selected Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 30, 2010 Moderators Share Posted October 30, 2010 Ace08, Use a message handler to intercept the click and determine the item/subitem like this: expandcollapse popup#include <GuiMenu.au3> #include <WindowsConstants.au3> #include <GuiConstantsEx.au3> #include <GuiListView.au3> #include <GuiImageList.au3> $hGUI = GUICreate('Read ListView Item', 400, 300) $hListView = _GUICtrlListView_Create($hGUI, "", 2, 2, 394, 268) _GUICtrlListView_SetExtendedListViewStyle($hListView, $LVS_EX_GRIDLINES) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Add columns _GUICtrlListView_InsertColumn($hListView, 0, "Column 1", 100) _GUICtrlListView_InsertColumn($hListView, 1, "Column 2", 100) _GUICtrlListView_InsertColumn($hListView, 2, "Column 3", 100) ; Add items _GUICtrlListView_AddItem($hListView, "Row 1: Col 1", 0) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 2", 1) _GUICtrlListView_AddSubItem($hListView, 0, "Row 1: Col 3", 2) _GUICtrlListView_AddItem($hListView, "Row 2: Col 1", 1) _GUICtrlListView_AddSubItem($hListView, 1, "Row 2: Col 2", 1) _GUICtrlListView_AddItem($hListView, "Row 3: Col 1", 2) GUISetState() ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func ListView_Click() EndFunc ;==>ListView_Click Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) ;$iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) ; Get id of clicked item If $aHit[0] <> -1 Then ; Check it was an item Local $sText = _GUICtrlListView_GetItemText($hListView, $aHit[0], $aHit[1]); Read the item text ConsoleWrite($sText & @CRLF) ; Display it EndIf Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY M23 P.S. I happened to have that script lying around, so it took almost no time to alter it. It greatly increases your chances of getting help if you provide a running script rather than just a few lines - having to write a whole script to show a solution is more than many here are prepared to do. 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 Link to comment Share on other sites More sharing options...
Ace08 Posted November 2, 2010 Author Share Posted November 2, 2010 (edited) Just came back from a long holiday Wow Thanks a lot Melba23 for the sample and Sorry for not posting the whole script i thought that it was just a small code that i overlooked oh and one more question, when i used the code above i noticed that the entire line isn't highligted anymore exept only for the first column Edited November 2, 2010 by Ace08 Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 2, 2010 Moderators Share Posted November 2, 2010 Ace08, the entire line isn't highligted anymoreJust add the relevant style: _GUICtrlListView_SetExtendedListViewStyle($hListView, BitOr($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) 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 Link to comment Share on other sites More sharing options...
Ace08 Posted November 2, 2010 Author Share Posted November 2, 2010 Thanks a lot Melba23 i'll try this one (so its just in the design part )Thanks again Work smarter not harder.My First Posted Script: DataBase Link to comment Share on other sites More sharing options...
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