Jump to content

Get multiple lines from list or listview


 Share

Go to solution Solved by mike2003,

Recommended Posts

I tried several ways and none work.

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$ListView1 = GUICtrlCreateListView("", 24, 24, 250, 150, BitOR($LVS_LIST,$LVS_SHOWSELALWAYS))
$ListView1_0 = GUICtrlCreateListViewItem("asdadad", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("adsad", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("2323", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("454545", $ListView1)
$Edit1 = GUICtrlCreateEdit("-", 312, 200, 185, 89)
$Button1 = GUICtrlCreateButton("Button1", 128, 224, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Edit1,GUICtrlRead(GUICtrlRead($ListView1)))
    EndSwitch
WEnd

Help page has no information about the reading. Only strange GUICtrlRead(GUICtrlRead($ListView1)). return only first selected line

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 616, 439, 192, 124)
$List1 = GUICtrlCreateList("", 112, 80, 121, 97, BitOR($GUI_SS_DEFAULT_LIST,$LBS_MULTIPLESEL))
GUICtrlSetData(-1, "34345|af5555|asdfasdf|nnbn")
$Button1 = GUICtrlCreateButton("Button1", 120, 232, 75, 25)
$Edit1 = GUICtrlCreateEdit("-", 280, 232, 185, 89)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            GUICtrlSetData($Edit1, GUICtrlRead($List1))
    EndSwitch
WEnd

Always returns the last line where the mouse clicked.
even if not selected.

How?

Edited by mike2003
Link to comment
Share on other sites

Napkin code edited from a program I made, but it will point you in the right direction:

#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Date.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
Global $BatchWidth = 350, $BatchHeight = 500
Global $hBtnSelectBatches = 50
Global $btnProcessBatches = 9999
Global $BatchesForm, $lstBatches
 
ChooseBatches()
 
While 1
$aMsg = GUIGetMsg(1)
Switch $aMsg[1]
Case $BatchesForm
Switch $aMsg[0]
Case $GUI_EVENT_CLOSE
$btnProcessBatches = 9999
GUIDelete($BatchesForm)
Case $btnProcessBatches
GUISetState(@SW_HIDE)
ProcessBatches()
EndSwitch
EndSwitch
WEnd
 
 
 
Func ChooseBatches()
Local $x, $todaydate
Local $FormTitle = "Select Some Dates!"
$BatchesForm = GUICreate($FormTitle, $BatchWidth, $BatchHeight, (@DesktopWidth - $BatchWidth) / 2, (@DesktopHeight - $BatchHeight) / 2, $WS_SYSMENU ) ;$WS_SIZEBOX
$lstBatches = GUICtrlCreateListView("", 0, 0, $BatchWidth-4, $BatchHeight - $hBtnSelectBatches - 25 - 8,BitOr($LVS_SHOWSELALWAYS, $LVS_REPORT), $LVS_SORTASCENDING)
_GUICtrlListView_InsertColumn($lstBatches,0,"Batch Date",$BatchWidth-30)
_GUICtrlListView_AddItem($lstBatches,"Current Date")
$todaydate = @YEAR & "/" & @MON & "/" & @MDAY
For $x = 1 To 100
_GUICtrlListView_AddItem($lstBatches,_DateAdd("d",-$x,$todaydate))
Next
$btnProcessBatches = GUICtrlCreateButton("Review Selected Dates", ($BatchWidth/2)-4, $BatchHeight - $hBtnSelectBatches - 25 - 4 ,($BatchWidth/2)-4,$hBtnSelectBatches)
GUISetState(@SW_SHOW)
EndFunc
 
Func ProcessBatches()
Local $tmparr
$tmparr = _GUICtrlListView_GetSelectedIndices($lstBatches,True)
For $x = 1 to $tmparr[0]
$tmparr[$x] = _GUICtrlListView_GetItemText($lstBatches,$tmparr[$x])
Next
_ArrayDisplay($tmparr)
EndFunc
Edited by kaisies
Link to comment
Share on other sites

  • Solution

thanks! key is

            Local $tmparr = _GUICtrlListView_GetSelectedIndices($ListView1, True)
            For $x = 1 To $tmparr[0]
                GUICtrlSetData($Edit1,_GUICtrlListView_GetItemText($ListView1, $tmparr[$x]) & @CRLF, True)
            Next
            GUICtrlSetData($Edit1,"---" & @CRLF, True)
full simple version with ListView

#include <GuiListView.au3>

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 615, 438, 192, 124)
$ListView1 = GUICtrlCreateListView("", 24, 24, 250, 150, BitOR($LVS_LIST, $LVS_SHOWSELALWAYS))
$ListView1_0 = GUICtrlCreateListViewItem("asdadad", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("adsad", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("2323", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("454545", $ListView1)
$Edit1 = GUICtrlCreateEdit("", 312, 200, 185, 189)
$Button1 = GUICtrlCreateButton("Button1", 128, 224, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Local $tmparr = _GUICtrlListView_GetSelectedIndices($ListView1, True)
            For $x = 1 To $tmparr[0]
                GUICtrlSetData($Edit1,_GUICtrlListView_GetItemText($ListView1, $tmparr[$x]) & @CRLF, True)
            Next
            GUICtrlSetData($Edit1,"---" & @CRLF, True)
    EndSwitch
WEnd
PS how insert colored code? :) Edited by mike2003
Link to comment
Share on other sites

  • Moderators

mike2003,

The editor has 2 modes - WYSIWYG and basic - which are toggled by the button at top left. If you are in WYSIWYG mode then you will see a small blue "A" icon about halfway along the bottom row - that is the "code insertion" button. :)

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

:P

It's this button

post-86910-0-05356900-1415119128.png

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

mike2003,

Oh ye of little faith! Why on earth would I tell you something that was not correct? :huh:

The code is not coloured until you post and the forum software does some Geshi magic depending on its syntax. Go and test in the "Test posting" section if you still do not believe me. ;)

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

  • Moderators

mike2003,

Looking at the tags in that post it starts: code=nocode:0 which is used for plain text. You must make sure that the dropdown in the code insertion dialog is set to "AutoIt". It really does work for the rest of us - we are not trolling you. :)

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

post-86910-0-75503800-1415129167_thumb.p

gives you this when you press okay:

;example code here

All clear? :)

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

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