Jump to content

why does GUICtrlRead($ListView) return a number and not the value of the selected list-item


Sl4yer
 Share

Recommended Posts

Why does "GUICtrlRead($dlistView)" return "6" when the first entry (c: | ntfs) is selected???

note: the function GUICtrlRead is called after a button is submitted

$dlistView = GuiCtrlCreateListView("Laufwerk|Dateisystem|", 20, 40, 200, 60)

$dVar = DriveGetDrive( "fixed" )
If NOT @error Then
    For $i = 1 to $dVar[0]
        $dglVar1 = DriveGetFileSystem($dVar[$i] & "\" )
        GuiCtrlCreateListViewItem($dVar[$i] & "|" & $dglVar1, $dlistView)
    Next
EndIf

pls help

Edited by Sl4yer
Link to comment
Share on other sites

Using GUICtrlRead() on a ListView returns the control-id of the selected ListViewItem!!

ListView | Control identifier (controlID) of the selected ListViewItem. 0 means no item is selected

Link to comment
Share on other sites

Sl4yer

Example:

#include <GuiConstantsEx.au3>

$hGUI = GUICreate("Test", 300, 200)

$hListView = GUICtrlCreateListView("Items|SubItems", 10, 10, 280, 160)

For $i = 1 To 10
    GUICtrlCreateListViewItem("Item " & $i & "|" & "SubItem " & $i, $hListView)
Next

$ReadButton = GUICtrlCreateButton("Read", 10, 173, 75, 23)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Switch $msg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $ReadButton
            ConsoleWrite(GUICtrlRead(GUICtrlRead($hListView)) & @LF)
    EndSwitch
WEnd
Link to comment
Share on other sites

You'd want to combine the index with a _GUICtrlListView_GetItemText

yehaw! got it to work with the following:

$ret = _GUICtrlListViewGetItemText($dlistView, _GUICtrlListViewGetSelectedIndices($dlistView))
            
            If ($ret <> $LV_ERR) Then
                MsgBox(0, "Selected Item", $ret)
                $ret = _GUICtrlListViewGetItemText($dlistView, _GUICtrlListViewGetSelectedIndices($dlistView), 0)
                
                    If ($ret <> $LV_ERR) Then
                        MsgBox(0, "Selected Item, SubItem 0", $ret)
                    EndIf
                    
            Else
                GUICtrlSetData($Status, "Nothing Selected")
            EndIf

thnx guys 4 ur help i appreciate it

Edited by Sl4yer
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...