找回密码
 加入
搜索
查看: 8505|回复: 15

[系统综合] List1内容通过按钮点击到List2显示,反过来也可以,显示是追加[已解决]

  [复制链接]
发表于 2010-10-13 17:14:53 | 显示全部楼层 |阅读模式
本帖最后由 dhh45 于 2010-10-15 09:21 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateList("", 72, 56, 105, 188)
GUICtrlSetData(-1,"test1")
GUICtrlSetData(-1,"test2")
GUICtrlSetData(-1,"test3")
GUICtrlSetData(-1,"test4")
GUICtrlSetData(-1,"test5")
GUICtrlSetData(-1,"test6")
GUICtrlSetData(-1,"test7")
GUICtrlSetData(-1,"test8")


$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$List2 = GUICtrlCreateList("", 344, 64, 113, 175)
$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit

        EndSwitch
WEnd
显示是追加的意思是List2中显示内容是选择List1内容后点击>或>>按钮后List1选中的内容显示在List2中的最后,List1中选中的内容不存在,不知道我这样表述大家是否明白啊?如何编写?

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-10-13 17:28:10 | 显示全部楼层
显示是追加的意思是List2中显示内容是选择List1内容后点击>或>>按钮后List1选中的内容显示在List2中的最后,不知道我这样表述大家是否明白啊?

不明白。。。。。。。。。。。。。。。。
发表于 2010-10-13 18:05:59 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateList("", 72, 56, 105, 188)
GUICtrlSetData(-1,"test1")
GUICtrlSetData(-1,"test2")
GUICtrlSetData(-1,"test3")
GUICtrlSetData(-1,"test4")
GUICtrlSetData(-1,"test5")
GUICtrlSetData(-1,"test6")
GUICtrlSetData(-1,"test7")
GUICtrlSetData(-1,"test8")
Local $li

$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
;$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
;$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$List2 = GUICtrlCreateList("", 344, 64, 113, 175)
;$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                Case $Button1
                                                $li=GUICtrlRead($List1)
                                                GUICtrlSetData($List2,$li)
        EndSwitch
WEnd
 楼主| 发表于 2010-10-13 20:04:15 | 显示全部楼层
回复 2# 131738

图片中点击>按钮后,test5显示在test8的下方

test5不在list1中,在list2中

图片不好弄,弄的不好看,意思明白就可以了

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-10-13 21:58:38 | 显示全部楼层
本帖最后由 飘云 于 2010-10-13 22:41 编辑

包含#Include <GuiListBox.au3>后,用_GUICtrlListBox_InsertString($List2, GUICtrlRead($List1))来添加信息到$List2,用_GUICtrlListBox_DeleteString($List1,_GUICtrlListBox_GetCurSel($List1))来将$List1中的那个项目删除

代码大概就这样
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateList("", 72, 56, 105, 188)
GUICtrlSetData(-1,"test1")
GUICtrlSetData(-1,"test2")
GUICtrlSetData(-1,"test3")
GUICtrlSetData(-1,"test4")
GUICtrlSetData(-1,"test5")
GUICtrlSetData(-1,"test6")
GUICtrlSetData(-1,"test7")
GUICtrlSetData(-1,"test8")


$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$List2 = GUICtrlCreateList("", 344, 64, 113, 175)
$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _GUICtrlListBox_InsertString($List2, GUICtrlRead($List1))
                        _GUICtrlListBox_DeleteString($List1,_GUICtrlListBox_GetCurSel($List1))
                Case $Button2
                        _GUICtrlListBox_InsertString($List1, GUICtrlRead($List2))
                        _GUICtrlListBox_DeleteString($List2,_GUICtrlListBox_GetCurSel($List2))
        EndSwitch
WEnd

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

发表于 2010-10-13 22:08:20 | 显示全部楼层
如果你想留空位的话,可以不使用_GUICtrlListBox_DeleteString函数,而使用_GUICtrlListBox_ReplaceString($hWnd, $iIndex, $sText),同样,可以先用_GUICtrlListBox_InsertString插入99个空文本,然后用_GUICtrlListBox_ReplaceString替换对应索引项的文本也可
 楼主| 发表于 2010-10-14 08:53:34 | 显示全部楼层
谢谢你啊!
可以先用_GUICtrlListBox_InsertString插入99个空文本   这个似乎不太好,有没有其他方法了啊?
发表于 2010-10-14 10:17:39 | 显示全部楼层
换成空格。
 楼主| 发表于 2010-10-14 10:42:51 | 显示全部楼层
我的意思是否有其他思路
发表于 2010-10-14 11:43:21 | 显示全部楼层
本帖最后由 liufenglg 于 2010-10-14 11:45 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <WindowsConstants.au3>
#include <array.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateList("", 72, 56, 105, 188)
GUICtrlSetData(-1,"test1")
GUICtrlSetData(-1,"test2")
GUICtrlSetData(-1,"test3")
GUICtrlSetData(-1,"test4")
GUICtrlSetData(-1,"test5")
GUICtrlSetData(-1,"test6")
GUICtrlSetData(-1,"test7")
GUICtrlSetData(-1,"test8")
 Local $con=_GUICtrlListBox_GetCount($List1)
 Local $array[$con]
 For $i=0 To $con-1
         $array[$i]=_GUICtrlListBox_GetText($List1,$i)
 Next
;_ArrayDisplay($array) 
 
$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$List2 = GUICtrlCreateList("", 344, 64, 113, 175)
$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                                        Case $Button1
                                                
                                                For $i=0 To $con-1 
                            If $array[$i]=GUICtrlRead($List1) Then 
                                                                _GUICtrlListBox_InsertString($List2, GUICtrlRead($List1))
                               _GUICtrlListBox_ReplaceString($List1,$i,'')
                                                   EndIf
                                                Next 
                                        Case $Button2
                                                For $i=0 To $con-1 
                                                        If $array[$i]=GUICtrlRead($List2) Then 
                       
                               _GUICtrlListBox_ReplaceString($List1,$i, GUICtrlRead($List2))
                                                   EndIf
                                                 Next  
        EndSwitch
WEnd

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2010-10-14 13:25:03 | 显示全部楼层
收藏了,谢谢楼主分享!
 楼主| 发表于 2010-10-14 15:32:09 | 显示全部楼层
这太丑了,谁的软件这样啊,我相信一定有好的,在研究中
发表于 2010-10-14 15:57:50 | 显示全部楼层
这太丑了,谁的软件这样啊,我相信一定有好的,在研究中
dhh45 发表于 2010-10-14 15:32



   没道德
 楼主| 发表于 2010-10-14 16:16:06 | 显示全部楼层
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <GUIListview.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 623, 449, 192, 114)
$List1 = GUICtrlCreateListView("", 72, 56, 105, 188)
_GUICtrlListView_AddItem($List1,"test1",0)
_GUICtrlListView_AddItem($List1,"test2",1)
_GUICtrlListView_AddItem($List1,"test3",2)
_GUICtrlListView_AddItem($List1,"test4",3)
_GUICtrlListView_AddItem($List1,"test5",4)
_GUICtrlListView_AddItem($List1,"test6",5)
_GUICtrlListView_AddItem($List1,"test7",6)
_GUICtrlListView_AddItem($List1,"test8",7)

GUICtrlSetStyle($List1,BitOR($lvs_list,$lvs_showselalways))
 
 
$Button1 = GUICtrlCreateButton(">", 216, 64, 89, 33)
$Button2 = GUICtrlCreateButton("<", 216, 112, 89, 33)
$Button3 = GUICtrlCreateButton(">>", 216, 160, 89, 41)
$List2 = GUICtrlCreateListView("", 344, 64, 113, 175)
GUICtrlSetStyle($List2,BitOR($lvs_list,$lvs_showselalways))
$Button4 = GUICtrlCreateButton("<<", 216, 208, 89, 41)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
 
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                                                _GUICtrlListView_CopyItems(GUICtrlGetHandle($List1),GUICtrlGetHandle($List2),True)
                Case $Button2
                      _GUICtrlListView_CopyItems(GUICtrlGetHandle($List2),GUICtrlGetHandle($List1),True)
                                Case $Button3
                                          $dd=""
                                          $dd=_GUICtrlListView_GetItemCount(GUICtrlGetHandle($List1))
                                          For $i=0 To $dd-1
                                                  _GUICtrlListView_SetItemSelected(GUICtrlGetHandle($List1),$i,True)
                                          Next
                                         _GUICtrlListView_CopyItems(GUICtrlGetHandle($List1),GUICtrlGetHandle($List2),True)
                                 Case $Button4
                                          $dd=""
                                          $dd=_GUICtrlListView_GetItemCount(GUICtrlGetHandle($List2))
                                          For $i=0 To $dd-1
                                                  _GUICtrlListView_SetItemSelected(GUICtrlGetHandle($List2),$i,True)
                                          Next
                                         _GUICtrlListView_CopyItems(GUICtrlGetHandle($List2),GUICtrlGetHandle($List1),True)
        EndSwitch
WEnd
 楼主| 发表于 2010-10-14 16:17:22 | 显示全部楼层
回复 13# liufenglg

不是我没有道德,不符合需求的代码有什么用啊,最终的问题是解决问题,我不是说研究了嘛
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-6-12 00:34 , Processed in 0.095339 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表