List1内容通过按钮点击到List2显示,反过来也可以,显示是追加[已解决]
本帖最后由 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中选中的内容不存在,不知道我这样表述大家是否明白啊?如何编写? 显示是追加的意思是List2中显示内容是选择List1内容后点击>或>>按钮后List1选中的内容显示在List2中的最后,不知道我这样表述大家是否明白啊?
不明白。。。。。。。。。。。。。。。。 #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 回复 2# 131738
图片中点击>按钮后,test5显示在test8的下方
test5不在list1中,在list2中
图片不好弄,弄的不好看,意思明白就可以了 本帖最后由 飘云 于 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 如果你想留空位的话,可以不使用_GUICtrlListBox_DeleteString函数,而使用_GUICtrlListBox_ReplaceString($hWnd, $iIndex, $sText),同样,可以先用_GUICtrlListBox_InsertString插入99个空文本,然后用_GUICtrlListBox_ReplaceString替换对应索引项的文本也可 谢谢你啊!
可以先用_GUICtrlListBox_InsertString插入99个空文本 这个似乎不太好,有没有其他方法了啊? 换成空格。 我的意思是否有其他思路 本帖最后由 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
收藏了,谢谢楼主分享! 这太丑了,谁的软件这样啊,我相信一定有好的,在研究中 这太丑了,谁的软件这样啊,我相信一定有好的,在研究中
dhh45 发表于 2010-10-14 15:32 http://www.autoitx.com/images/common/back.gif
没道德
#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 回复 13# liufenglg
不是我没有道德,不符合需求的代码有什么用啊,最终的问题是解决问题,我不是说研究了嘛
页:
[1]
2