Jump to content
Sign in to follow this  
Sl4yer

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

Recommended Posts

Sl4yer

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

Share this post


Link to post
Share on other sites
AdmiralAlkex

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

Share this post


Link to post
Share on other sites
rasim

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

Share this post


Link to post
Share on other sites
Sl4yer

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.