Jump to content
Sign in to follow this  
beast

_GUICtrlListView

Recommended Posts

beast

I have try exemple in Autoit help and search this forum on geting selected value from _GUICtrlListView.

But i don't find anything on geting selected, all exempel select from code and then somthing with _GetItemTextString or GetItemSelected.

Some exemple on this forum use GetItemText with GetSelectedIndices.

Can some one help me and give a simple exemple white Form,  _GUICtrlListView and input, there input feld showing users mouse selected value from ListView.

Edited by beast

Share this post


Link to post
Share on other sites
beast

_GUICtrlListView_GetItemText will return the text of a ListView item or a subitem.  Is that what you are after?

 

Every time When i select a row in ListView, I want valu from this row into a variable, i have read some more and think i need a loop.

I have try somthing like this and it look like variable is set but Input valu is not change.

.
.
$IUser = GUICtrlCreateInput($IUser, 241, 8, 159, 21)
.
.
.
Case $hListView
$Indices =_GUICtrlListView_GetSelectedIndices($hListView)
$Indices = StringSplit($Indices, "|")
For $IX = 1 To $Indices[0] Step 1
$TXTITEM =_GUICtrlListView_GetItemText($hListView, int($Indices[$IX]))
$DlgItem = _WinAPI_SetFocus(_WinAPI_GetDlgItem($hwnd, $hListView))
$ItemFocused = _GUICtrlListView_GetItemFocused($hListView, int($Indices[$IX]))
if $ItemFocused = True Then  $IUser2 = $TXTITEM
Next
$IUser = GUICtrlSetData($IUser,$Iuser2)
Edited by beast

Share this post


Link to post
Share on other sites
beast

 

Every time When i select a row in ListView, I want valu from this row into a variable, i have read some more and think i need a loop.

I have try somthing like this and it look like variable is set but Input valu is not change.

.
.
$IUser = GUICtrlCreateInput($IUser, 241, 8, 159, 21)
.
.
.
Case $hListView
$Indices =_GUICtrlListView_GetSelectedIndices($hListView)
$Indices = StringSplit($Indices, "|")
For $IX = 1 To $Indices[0] Step 1
$TXTITEM =_GUICtrlListView_GetItemText($hListView, int($Indices[$IX]))
$DlgItem = _WinAPI_SetFocus(_WinAPI_GetDlgItem($hwnd, $hListView))
$ItemFocused = _GUICtrlListView_GetItemFocused($hListView, int($Indices[$IX]))
if $ItemFocused = True Then  $IUser2 = $TXTITEM
Next
$IUser = GUICtrlSetData($IUser,$Iuser2)

No one

Share this post


Link to post
Share on other sites
Melba23

beast,

How about this?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiListView.au3>

; Variable to hold selected row content
Global $sRowContent

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("", 10, 10, 480, 250)
For $i = 0 To 3
    _GUICtrlListView_AddColumn($cLV, "Col " & $i, 115)
Next
For $i = 0 To 9
    GUICtrlCreateListViewItem($i & "-0|" & $i & "-1|" & $i & "-2|" & $i & "-3|", $cLV)
Next

; Create a dummy conteol to fire when the selection changes
$cItemSelected = GUICtrlCreateDummy()

GUISetState()

; Register WM_NOTIFY
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cItemSelected
            ; Selection changed so display contetn of new row
            MsgBox($MB_SYSTEMMODAL, "Selected", $sRowContent)
    EndSwitch
WEnd

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    Switch BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Code
        Case $NM_CLICK
            $sRowContent = _GUICtrlListView_GetItemTextString($cLV, DllStructGetData($tStruct, 4)) ; Row
            ; Fire dummy control
            GUICtrlSendToDummy($cItemSelected)
    EndSwitch

EndFunc
Please ask if you have any questions. :)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
beast

beast,

How about this?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiListView.au3>

; Variable to hold selected row content
Global $sRowContent

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("", 10, 10, 480, 250)
For $i = 0 To 3
    _GUICtrlListView_AddColumn($cLV, "Col " & $i, 115)
Next
For $i = 0 To 9
    GUICtrlCreateListViewItem($i & "-0|" & $i & "-1|" & $i & "-2|" & $i & "-3|", $cLV)
Next

; Create a dummy conteol to fire when the selection changes
$cItemSelected = GUICtrlCreateDummy()

GUISetState()

; Register WM_NOTIFY
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cItemSelected
            ; Selection changed so display contetn of new row
            MsgBox($MB_SYSTEMMODAL, "Selected", $sRowContent)
    EndSwitch
WEnd

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    Switch BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Code
        Case $NM_CLICK
            $sRowContent = _GUICtrlListView_GetItemTextString($cLV, DllStructGetData($tStruct, 4)) ; Row
            ; Fire dummy control
            GUICtrlSendToDummy($cItemSelected)
    EndSwitch

EndFunc
Please ask if you have any questions. :)

M23

 

 

All exemple when valu is in MsgBox works for me to, if I use this in my code

if $ItemFocused = True Then MsgBox(4160, "Information", "Item Focused: " & $TXTITEM)

It work, but cant get this valu in my InputBox

>>>$IUser = GUICtrlCreateInput($IUser, 241, 8, 159, 21)<<<<<

is it not posible to change the input valu on the fly and it while update for user.

I list username from AD in my ListView and when user select from it it sholde update the InputBox..

I was thinking

if $ItemFocused = True Then  $IUser2 = $TXTITEM

Next

$IUser = GUICtrlSetData($IUser,$Iuser2)

sholde update $IUser in my InputeBox.

Share this post


Link to post
Share on other sites
Melba23

beast,

Just replace the MsgBox line with a GUICtrlSetData line: :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <GuiListView.au3>

; Variable to hold selected row content
Global $sRowContent

$hGUI = GUICreate("Test", 500, 500)

$cLV = GUICtrlCreateListView("", 10, 10, 480, 250)
For $i = 0 To 3
    _GUICtrlListView_AddColumn($cLV, "Col " & $i, 115)
Next
For $i = 0 To 9
    GUICtrlCreateListViewItem($i & "-0|" & $i & "-1|" & $i & "-2|" & $i & "-3|", $cLV)
Next

; Create an input
$IUser = GUICtrlCreateInput("", 10, 300, 159, 21) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

; Create a dummy control to fire when the selection changes
$cItemSelected = GUICtrlCreateDummy()

GUISetState()

; Register WM_NOTIFY
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $cItemSelected
            ; Selection changed so change input content
            GUICtrlSetData($IUser, $sRowContent) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            ;MsgBox($MB_SYSTEMMODAL, "Selected", $sRowContent)
    EndSwitch
WEnd

Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam

    Local $tStruct = DllStructCreate("hwnd;uint_ptr;int_ptr;int;int", $lParam)
    Switch BitAND(DllStructGetData($tStruct, 3), 0xFFFFFFFF) ; Code
        Case $NM_CLICK
            $sRowContent = _GUICtrlListView_GetItemTextString($cLV, DllStructGetData($tStruct, 4)) ; Row
            ; Fire dummy control
            GUICtrlSendToDummy($cItemSelected)
    EndSwitch

EndFunc
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

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  

×