为什么从ListView里读取的数据不能添加到combox里面。已解决
本帖最后由 udbghdto 于 2011-8-8 13:42 编辑为什么从ListView里读取的数据不能添加到combox里面。可以添加inpux输入框里。奇怪了。
$Sting = GUICtrlRead(GUICtrlRead($ListView1))
$Stingspin = StringSplit($Sting, "|")
GUICtrlSetData($combox1, $Strnspin)
这样不行。。
下面的代码。。怎么读取$ListView1字段“A”里面的数据, 让combo显示"A"字段里面的数据#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 515, 279, 192, 124)
$ListView1 = GUICtrlCreateListView("A|B|C", 48, 24, 169, 193)
$item1 = GUICtrlCreateListViewItem("项1|子项1|123", $ListView1)
$item3 = GUICtrlCreateListViewItem("项2|子项2|456", $ListView1)
$item4 = GUICtrlCreateListViewItem("项3|子项3|789", $ListView1)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
$Combo1 = GUICtrlCreateCombo("", 248, 80, 225, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
combox以及ListView都是用"|" 分割数据的? 没看到你的完整代码 不知道是不是添加了非法字符等等!
在GUICtrlSetData($combox1, $Strnspin)
下面加句
msgbox(0,"",@error)看看是不是-1 如果是 说明给的数据无效! 本帖最后由 udbghdto 于 2011-8-7 22:37 编辑
#include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 515, 279, 192, 124)
$ListView1 = GUICtrlCreateListView("A|B|C", 48, 24, 169, 193)
$item1 = GUICtrlCreateListViewItem("项1|子项1|123", $ListView1)
$item3 = GUICtrlCreateListViewItem("项2|子项2|456", $ListView1)
$item4 = GUICtrlCreateListViewItem("项3|子项3|789", $ListView1)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
$Combo1 = GUICtrlCreateCombo("", 248, 80, 225, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd #include <ComboConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 515, 279, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Event")
$ListView1 = GUICtrlCreateListView("A|B|C", 48, 24, 169, 193)
$item1 = GUICtrlCreateListViewItem("项1|子项1|123", $ListView1)
GUICtrlSetOnEvent($item1, "Event")
$item3 = GUICtrlCreateListViewItem("项2|子项2|456", $ListView1)
GUICtrlSetOnEvent($item3, "Event")
$item4 = GUICtrlCreateListViewItem("项3|子项3|789", $ListView1)
GUICtrlSetOnEvent(-1, "Event")
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
$Combo1 = GUICtrlCreateCombo("", 248, 80, 225, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Sleep(100)
WEnd
Func Event()
Switch @GUI_CtrlId
Case $GUI_EVENT_CLOSE
Exit
Case Else
$Val = GUICtrlRead(@GUI_CtrlId, 1)
$Val = StringSplit($Val, "|", 1)
MsgBox("", $Val, $Val)
GUICtrlSetData($Combo1, $Val, $Val)
EndSwitch
EndFunc ;==>Event
页:
[1]