ac5474012 发表于 2011-5-10 17:45:37

如何双击列表中的一个值,这个值就移动到另一个列表。

本帖最后由 ac5474012 于 2011-5-17 14:26 编辑


1.如何双击123,这个123就移动到右边
2.如何让这个123变得厚一点(上下大)
3.如果多选?比如按住ctrl按键可以同时选中123和4567这两个?(这样就可以不用第一个了)



好像很多人对这个问题感兴趣,其实不难实现
才弄好,发现3M已经解决了,
发出来给大家参考
pcbar 发表于 2011-5-12 14:09 http://www.autoitx.com/images/common/back.gif

ac5474012 发表于 2011-5-11 11:32:08

什么?这很难吗?怎么没有人知道呢?

binshiwo 发表于 2011-5-11 17:25:24

這個問題在論壇里已經有答案了,自己搜索吧!

lxz 发表于 2011-5-11 17:39:10

自己搜索吧!

绿色风 发表于 2011-5-11 19:19:08

读取左边的选定的,再判断循环到右边去.

netegg 发表于 2011-5-11 21:09:49

回复 5# 绿色风
和判断关系不大

ac5474012 发表于 2011-5-12 09:52:35

回复 3# binshiwo

這個問題在論壇里已經有答案了,自己搜索吧!
binshiwo 发表于 2011-5-11 17:25 http://www.autoitx.com/images/common/back.gif

能给个关键词否?

ac5474012 发表于 2011-5-12 09:55:45

回复 4# lxz

那求个关键字吧,我搜索“列表”没有找到

ac5474012 发表于 2011-5-12 09:57:57

读取左边的选定的,再判断循环到右边去.
绿色风 发表于 2011-5-11 19:19 http://www.autoitx.com/images/common/back.gif

我可以得到选定的值,可以先删除左边的在新建右边的。但现在的问题是我找不到检测双击的方法?

binshiwo 发表于 2011-5-12 10:06:38

回复 7# ac5474012


http://www.autoitx.com/thread-6100-1-1.html

绿色风 发表于 2011-5-12 11:46:16

回复 9# ac5474012


    找说是这回事就行了嘛,看你写的要按按钮的...10楼有转向了

3mile 发表于 2011-5-12 11:54:57

1.左键双击移动到另一个LISTVIEW.
2.可CTRL多选.多选后右键移动到另一个LISTVIEW
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GuiImageList.au3>
$hGUI = GUICreate("LVN_ITEMCHECKING", 400, 400)

$ListView1 = GUICtrlCreateListView("Test|Val", 10, 10, 380, 180, $LVS_SHOWSELALWAYS, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT));, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
$hListView = GUICtrlGetHandle(-1)
$hImage = _GUIImageList_Create(1, 30);30为间距
_GUICtrlListView_SetImageList($ListView1, $hImage, 1)
For $I = 1 To 10
        GUICtrlCreateListViewItem("ITEM-" & $I & "|Val-" & $I, $ListView1)
Next


$ListView2 = GUICtrlCreateListView("Test1|Val1", 10, 190, 380, 180, $LVS_SHOWSELALWAYS);, Default, BitOR($LVS_EX_CHECKBOXES, 0x200))
;GUICtrlCreateListViewItem("Item 1", $iListView)
;GUICtrlCreateListViewItem("Item 2", $iListView)

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While GUIGetMsg() <> -3
WEnd
GUIDelete($hGUI)

Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)

        Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
        Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
        If @error Then Return $GUI_RUNDEFMSG
        $IDFrom = DllStructGetData($tagNMHDR, 2)
        $Event = DllStructGetData($tagNMHDR, 3)
        $tagNMHDR = 0
        Switch $IDFrom;选择产生事件的控件

                Case $ListView1

                        Switch $Event; 选择产生的事件
                                Case $NM_CLICK ; 左击
;~                                    ...
                                Case $NM_DBLCLK ; 双击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView1)
                                        If $Index = "" Then; 这里用以判断是否选定了ListViewItem
                                                Return
                                        EndIf
                                        _GUICtrlListView_AddItem($ListView2, _GUICtrlListView_GetItemText($ListView1, Number($Index), 0))
                                        _GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2) - 1, _GUICtrlListView_GetItemText($ListView1, Number($Index), 1), 1)
                                        _GUICtrlListView_DeleteItem($ListView1, Number($Index))
                                Case $NM_RCLICK ; 右击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView1, True)
                                        If $Index = 0 Then Return
                                        For $I = 1 To $Index
                                                _GUICtrlListView_AddItem(GUICtrlGetHandle($ListView2), _GUICtrlListView_GetItemText($ListView1, Number($Index[$I]), 0))
                                                _GUICtrlListView_AddSubItem($ListView2, _GUICtrlListView_GetItemCount($ListView2) - 1, _GUICtrlListView_GetItemText($ListView1, Number($Index[$I]), 1), 1)
                                        Next
                                        For $I = $Index To 1 Step -1
                                                _GUICtrlListView_DeleteItem($ListView1, Number($Index[$I]))
                                        Next
                        EndSwitch
                Case $ListView2
                        Switch $Event; 选择产生的事件
                                Case $NM_CLICK ; 左击
;~                                    ...
                                Case $NM_DBLCLK ; 双击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView2)
                                        If $Index = "" Then; 这里用以判断是否选定了ListViewItem
                                                Return
                                        EndIf
                                        _GUICtrlListView_AddItem($ListView1, _GUICtrlListView_GetItemText($ListView2, Number($Index), 0))
                                        _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, _GUICtrlListView_GetItemText($ListView2, Number($Index), 1), 1)
                                        _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView2), Number($Index))
                                Case $NM_RCLICK ; 右击
                                        $Index = _GUICtrlListView_GetSelectedIndices($ListView2, True)
                                        If $Index = 0 Then Return
                                        For $I = 1 To $Index
                                                _GUICtrlListView_AddItem(GUICtrlGetHandle($ListView1), _GUICtrlListView_GetItemText($ListView2, Number($Index[$I]), 0))
                                                _GUICtrlListView_AddSubItem($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1, _GUICtrlListView_GetItemText($ListView2, Number($Index[$I]), 1), 1)
                                        Next
                                        For $I = $Index To 1 Step -1
                                                _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView2), Number($Index[$I]))
                                        Next
                        EndSwitch
        EndSwitch

        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

pcbar 发表于 2011-5-12 14:09:47

好像很多人对这个问题感兴趣,其实不难实现
才弄好,发现3M已经解决了,
发出来给大家参考#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <array.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("test", 373, 274, 192, 124)
$List1 = _GUICtrlListBox_Create($Form1, "", 16, 48, 113, 201, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER ))
$List2 = _GUICtrlListBox_Create($Form1, "", 232, 48, 113, 201, BitOR($LBS_NOTIFY, $WS_VSCROLL, $WS_BORDER))
$Button1 = GUICtrlCreateButton(">>", 152, 64, 65, 25)
$Button2 = GUICtrlCreateButton("<<", 152, 126, 65, 25)
$Button3 = GUICtrlCreateButton("undo", 152, 200, 65, 25)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
updatel1()
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        u1()
                Case $Button2
                        u2()
                Case $Button3
                       
        EndSwitch
WEnd

Func updatel1()
        Local $l1
        For $i = 1 To 10
                $l1[$i - 1] = "软件 " & $i
        Next
        _GUICtrlListBox_BeginUpdate($List1)
        For $i = 1 To UBound($l1)
                _GUICtrlListBox_AddString($List1, $l1[$i - 1])
        Next
        _GUICtrlListBox_EndUpdate($List1)
EndFunc   ;==>updatel1


Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
        #forceref $hWnd, $iMsg
        Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
        ;$hWndListBox= GUICtrlGetHandle($List1)
        $hWndFrom = $ilParam
        $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
        $iCode = BitShift($iwParam, 16) ; Hi Word

        Switch $hWndFrom
                Case $List1;
                        Switch $iCode
                                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                                        u1()
                        EndSwitch
                Case $List2
                        Switch $iCode
                                Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
                                        u2()
                        EndSwitch
                       
        EndSwitch

        Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func u1()
        $n = _GUICtrlListBox_GetCurSel($List1)
        If $n = -1 Then Return
        $txt = _GUICtrlListBox_GetText($List1, $n)
        _GUICtrlListBox_AddString($List2, $txt)
        _GUICtrlListBox_DeleteString($List1, $n)
EndFunc   ;==>u1

Func u2()
        $n = _GUICtrlListBox_GetCurSel($List2)
        If $n = -1 Then Return
        $txt = _GUICtrlListBox_GetText($List2, $n)
        _GUICtrlListBox_AddString($List1, $txt)
        _GUICtrlListBox_DeleteString($List2, $n)
EndFunc   ;==>u2

pcbar 发表于 2011-5-12 14:12:01

为什么我的代码不是彩色的??{:face (207):}

3mile 发表于 2011-5-12 14:19:08

回复 14# pcbar
向前辈学习.
前辈用的是""吧?
如果用""就是彩色代码框.
页: [1] 2
查看完整版本: 如何双击列表中的一个值,这个值就移动到另一个列表。