Jump to content

Select items from one side to other in listview


 Share

Recommended Posts

I found this script and i want items from left side to stay there when i bring them to right side, so i can put the same item multiple times in the right side.Is this possible .Could anyone change the script so it does what i want ???

Thanks in advance

#include <GUIConstants.au3

; == GUI generated with Koda ==);

Dim $ItemList1 = "Coca Cola|Pizza|Amstel|Fanta|Water", $ItemList2 = ''

$Form5 = GUICreate("Form1", 405, 269, 227, 154)

$List1 = GUICtrlCreateList("", 16, 32, 129, 227)

GUICtrlSetData($List1, $ItemList1)

$GUI_AddButton = GUICtrlCreateButton("Add >>", 152, 88, 97, 25, 0)

GUICtrlSetState($GUI_AddButton,$GUI_FOCUS)

$GUI_CloseButton = GUICtrlCreateButton("<< Remove", 152, 152, 97, 25, 0)

$List2 = GUICtrlCreateList("", 256, 32, 129, 227)

GUISetState(@SW_SHOW)

While 1

$msg = GuiGetMsg()

Select

case $msg = $GUI_AddButton

If GUICtrlRead($List1) == "" Then

MsgBox(0,"", "Please Select Something to be moved")

Else

$ItemList2 = $ItemList2 & GUICtrlRead($List1) & "|"

$ItemList1 = _ChangeList($List1, $List2, $ItemList1, GUICtrlRead($List1))

EndIf

Case $msg = $GUI_CloseButton

If GUICtrlRead($List2) == "" Then

MsgBox(0,"", "Please Select Something to be moved")

Else

$ItemList1 = $ItemList1 & GUICtrlRead($List2) & "|"

$ItemList2 = _ChangeList($List2, $List1, $ItemList2, GUICtrlRead($List2))

EndIf

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case Else

;;;;;;;

EndSelect

WEnd

Func _ChangeList($i_FromCTRLID, $i_ToCTRLID, $s_ItemList, $s_ToAdd)

Local $aSplit = StringSplit($s_ItemList, '|'), $s_HoldValue = ''

For $iCount = 1 To UBound($aSplit) - 1

;MsgBox(0,"", "aSplit: " & $aSplit[$iCount])

If $aSplit[$iCount] <> $s_ToAdd And $aSplit[$iCount] <> '' Then

$s_HoldValue = $s_HoldValue & $aSplit[$iCount] & '|'

;MsgBox(0,"", "aSplit MATCHED RULE: " & $aSplit[$iCount] & " holdValue: " & $s_HoldValue)

EndIf

Next

GUICtrlSetData($i_FromCTRLID, '')

GUICtrlSetData($i_FromCTRLID, $s_HoldValue)

GUICtrlSetData($i_ToCTRLID, $s_ToAdd)

Return $s_HoldValue

EndFunc

Link to comment
Share on other sites

Think this is what you want:

#include <GUIConstants.au3>
#include <GuiList.au3>

; == GUI generated with Koda ==);
$Form5 = GUICreate("Form1", 405, 269, 227, 154)
$List1 = GUICtrlCreateList("", 16, 32, 129, 227)
GUICtrlSetData($List1, "Coca Cola|Pizza|Amstel|Fanta|Water")
$GUI_AddButton = GUICtrlCreateButton("Add >>", 152, 88, 97, 25, 0)
GUICtrlSetState($GUI_AddButton, $GUI_FOCUS)
$GUI_RemButton = GUICtrlCreateButton("<< Remove", 152, 152, 97, 25, 0)
$List2 = GUICtrlCreateList("", 256, 32, 129, 227)
GUISetState(@SW_SHOW)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_AddButton
            If _GUICtrlListSelectedIndex($List1) = $LB_ERR Then
                MsgBox(0, "", "Please Select Something to be moved")
            Else
                _GUICtrlListAddItem($List2,_GUICtrlListGetText($List1, _GUICtrlListSelectedIndex($List1)))
            EndIf
        Case $msg = $GUI_RemButton
            If _GUICtrlListSelectedIndex($List2) = $LB_ERR Then
                MsgBox(0, "", "Please Select Something to be moved")
            Else
                _GUICtrlListDeleteItem($List2, _GUICtrlListSelectedIndex($List2))
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case Else
            ;;;;;;;
    EndSelect
WEnd
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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