GUICtrlCreateListViewItem和_GUICtrlListView_AddItem有什么区别
我在listview控件中添加item子项时,开始时用的时_GUICtrlListView_AddItem和_GUICtrlListView_AddSubItem
结果发现无法使用_GUICtrlListView_DeleteItemsSelected 删除已添加的item项
代码如下
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 452, 193, 125)
$ListView1 = GUICtrlCreateListView("1|2|3|4", 56, 24, 418, 158)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlSendMsg(-1, 0x101E, 3, 100)
$Button1 = GUICtrlCreateButton("ADD", 112, 368, 75, 25, 0)
$Button2 = GUICtrlCreateButton("DEL", 296, 368, 75, 25, 0)
$Input1 = GUICtrlCreateInput("Input1", 81, 208, 95, 21)
$Input2 = GUICtrlCreateInput("Input2", 80, 248, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 80, 296, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
ADD()
Case $Button2
DEL()
EndSwitch
WEnd
Func ADD()
Local $num1,$num2,$num3,$Number
$num1=GUICtrlRead($Input1)
$num2=GUICtrlRead($Input2)
$num3=GUICtrlRead($Input3)
$Number = _GUICtrlListView_GetItemCount($ListView1)
_GUICtrlListView_AddItem($ListView1, $num1, $Number)
_GUICtrlListView_AddSubItem($ListView1, $Number, $num2, 1)
_GUICtrlListView_AddSubItem($ListView1, $Number, $num3, 2)
EndFunc
Func DEL()
_GUICtrlListView_DeleteItemsSelected ($ListView1)
EndFunc
后来使用GUICtrlCreateListViewItem添加子项后
子项就能被_GUICtrlListView_DeleteItemsSelected 删除了,不知道为什么?
Func ADD()
Local $num1,$num2,$num3
$num1=GUICtrlRead($Input1)
$num2=GUICtrlRead($Input2)
$num3=GUICtrlRead($Input3)
GUICtrlCreateListViewItem( $num1&"|"&$num2&"|"&$num3, $ListView1)
EndFunc
[ 本帖最后由 ken0137 于 2008-8-20 19:57 编辑 ] 还有哪个函数是可以取得listview里用鼠标所选择的那行的文本的
A:这个知道了
_GUICtrlListView_GetItemText($ListView3_1_1, _GUICtrlListView_GetNextItem($ListView3_1_1), 0)
[ 本帖最后由 ken0137 于 2008-8-18 22:53 编辑 ] 回复第二楼的问题:
$Code = _GUICtrlListView_GetSelectedIndices($ListView3_1_1)
$Text = _GUICtrlListView_GetItemText($ListView3_1_1, Number($Code), 0) 不知道谁能回答一楼的问题 第一个问题:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 452, 193, 125)
$ListView1 = GUICtrlCreateListView("1|2|3|4", 56, 24, 418, 158)
GUICtrlSendMsg(-1, 0x101E, 0, 100)
GUICtrlSendMsg(-1, 0x101E, 1, 100)
GUICtrlSendMsg(-1, 0x101E, 2, 100)
GUICtrlSendMsg(-1, 0x101E, 3, 100)
$Button1 = GUICtrlCreateButton("ADD", 112, 368, 75, 25, 0)
$Button2 = GUICtrlCreateButton("DEL", 296, 368, 75, 25, 0)
$Input1 = GUICtrlCreateInput("Input1", 81, 208, 95, 21)
$Input2 = GUICtrlCreateInput("Input2", 80, 248, 121, 21)
$Input3 = GUICtrlCreateInput("Input3", 80, 296, 121, 21)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
ADD()
Case $Button2
DEL()
EndSwitch
WEnd
Func ADD()
Local $num1,$num2,$num3,$Number
$num1=GUICtrlRead($Input1)
$num2=GUICtrlRead($Input2)
$num3=GUICtrlRead($Input3)
$Number = _GUICtrlListView_GetItemCount($ListView1)
_GUICtrlListView_AddItem($ListView1, $num1, $Number)
_GUICtrlListView_AddSubItem($ListView1, $Number, $num2, 1)
_GUICtrlListView_AddSubItem($ListView1, $Number, $num3, 2)
EndFunc
Func DEL()
_GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($ListView1))
EndFunc 3q~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 受益良多,学习下。 不错,不错。。。。。 很好,学习了 ~~~~~学习了~~
页:
[1]