找回密码
 加入
搜索
查看: 3392|回复: 9

GUICtrlCreateListViewItem和_GUICtrlListView_AddItem有什么区别

[复制链接]
发表于 2008-8-18 21:00:13 | 显示全部楼层 |阅读模式
我在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 编辑 ]
 楼主| 发表于 2008-8-18 21:24:24 | 显示全部楼层
还有哪个函数是可以取得listview里用鼠标所选择的那行的文本的
A:这个知道了
_GUICtrlListView_GetItemText($ListView3_1_1, _GUICtrlListView_GetNextItem($ListView3_1_1), 0)

[ 本帖最后由 ken0137 于 2008-8-18 22:53 编辑 ]
发表于 2008-8-19 09:58:29 | 显示全部楼层
回复第二楼的问题:

$Code = _GUICtrlListView_GetSelectedIndices($ListView3_1_1)
$Text = _GUICtrlListView_GetItemText($ListView3_1_1, Number($Code), 0)
 楼主| 发表于 2008-8-19 17:34:52 | 显示全部楼层
不知道谁能回答一楼的问题
发表于 2008-8-19 17:56:00 | 显示全部楼层
第一个问题:
#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
 楼主| 发表于 2008-8-20 19:57:03 | 显示全部楼层
3q~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
发表于 2009-3-13 19:34:35 | 显示全部楼层
受益良多,学习下。
发表于 2011-1-25 01:38:59 | 显示全部楼层
不错,不错。。。。。
发表于 2012-12-19 14:49:14 | 显示全部楼层
很好,学习了
发表于 2012-12-25 09:04:17 | 显示全部楼层
~~~~~学习了~~
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-11-18 08:21 , Processed in 0.096218 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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