Jump to content

_GUICtrlListView


beast
 Share

Go to solution Solved by Melba23,

Recommended Posts

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
Link to comment
Share on other sites

_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
Link to comment
Share on other sites

 

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

Link to comment
Share on other sites

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • Moderators
  • Solution

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

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...