找回密码
 加入
搜索
查看: 5909|回复: 8

[AU3基础] (已解决)listview函数,删除列可以,删除行不行。是不是我英语太差理解错了?

  [复制链接]
发表于 2010-12-19 21:01:01 | 显示全部楼层 |阅读模式
本帖最后由 330259789 于 2010-12-21 18:43 编辑

如题
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#Region ### START Koda GUI section ### Form=
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 623, 442, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")
$Button1 = GUICtrlCreateButton("Button1", 0, 0, 75, 25)
GUICtrlSetOnEvent(-1, "del")
$ListView1 = GUICtrlCreateListView("|||", 0, 20, 590, 224)
_GUICtrlListView_AddItem($ListView1, "")
_GUICtrlListView_AddItem($ListView1, "")
_GUICtrlListView_AddItem($ListView1, "")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
_GUICtrlListView_SetItemText($ListView1, 0, 123, 0)
        _GUICtrlListView_SetItemText($ListView1,1, 123, 0)
        _GUICtrlListView_SetItemText($ListView1, 2, 12312, 0)
        _GUICtrlListView_SetItemText($ListView1, 3, 123, 0)
        _GUICtrlListView_SetItemText($ListView1, 0, 341234, 1)
        _GUICtrlListView_SetItemText($ListView1, 1, 324124, 1)
        _GUICtrlListView_SetItemText($ListView1, 2, 12341234, 1)
        _GUICtrlListView_SetItemText($ListView1, 3, 2341235, 1)
        _GUICtrlListView_SetItemText($ListView1, 0, 23412341, 2)
        _GUICtrlListView_SetItemText($ListView1,1, 231412351235, 2)
While 1

WEnd
Func del()
                If _GUICtrlListView_DeleteColumn($ListView1,1) Then
                MsgBox(0,0,"删除列成功")
        Else
                MsgBox(0,0,"删除列失败")
                EndIf
        If _GUICtrlListView_DeleteItem($ListView1,0) Then
                MsgBox(0,0,"删除行成功")
        Else
                MsgBox(0,0,"删除行失败")
                EndIf
EndFunc   ;==>del


Func Close()
        Exit
EndFunc   ;==>Close

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-12-19 21:26:48 | 显示全部楼层

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Form1", 805, 305, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Close")

$Button1 = GUICtrlCreateButton("del1", 2, 2, 75, 25)
GUICtrlSetOnEvent(-1, "del1")

$ListView1 = _GUICtrlListView_Create($Form1, "col1|col2|col3", 2, 30, 394, 268)
Dim $aItems[10][3]
For $iI = 0 To UBound($aItems) - 1
        $aItems[$iI][0] = "Item " & $iI
        $aItems[$iI][1] = "Item " & $iI & "-1"
        $aItems[$iI][2] = "Item " & $iI & "-2"
Next
_GUICtrlListView_AddArray($ListView1, $aItems)

$Button1 = GUICtrlCreateButton("del2", 400, 2, 75, 25)
GUICtrlSetOnEvent(-1, "del2")

$ListView2 = GUICtrlCreateListView("col1|col2|col3", 402, 30, 394, 268)
For $iI = 0 To 9
        GUICtrlCreateListViewItem("Item " & $iI & "|Item " & $iI & "-1|Item " & $iI & "-2", $ListView2)
Next

GUISetState(@SW_SHOW)

While 1
        Sleep(10000)
WEnd

Func del1()
        MsgBox(0,"","ListView1删除列:"&_GUICtrlListView_DeleteColumn($ListView1,1))
        MsgBox(0,"","ListView1删除行:"&_GUICtrlListView_DeleteItem($ListView1,1))
EndFunc   ;==>del

Func del2()
        MsgBox(0,"","ListView2删除列:"&_GUICtrlListView_DeleteColumn($ListView2,1))
        MsgBox(0,"","ListView2删除行:"&_GUICtrlListView_DeleteItem($ListView2,1))
EndFunc   ;==>del

Func Close()
        Exit
EndFunc   ;==>Close

评分

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

查看全部评分

发表于 2010-12-19 21:30:59 | 显示全部楼层
_GUICtrlListView_DeleteItem 是删除行
_GUICtrlListView_DeleteColumn 是删除列
 楼主| 发表于 2010-12-19 21:56:21 | 显示全部楼层
回复 2# 298311657

你的是可以的,可是为什么我的代码就是不行啊?
我用的也是_GUICtrlListView_DeleteItem啊
 楼主| 发表于 2010-12-19 21:57:17 | 显示全部楼层
回复 3# yhxhappy

函数我写的应该没错吧?可是为什么删除不了呢?
发表于 2010-12-19 23:20:59 | 显示全部楼层
_GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView1), 1)

评分

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

查看全部评分

 楼主| 发表于 2010-12-21 18:43:19 | 显示全部楼层
回复 6# yhxhappy


果然可以,谢啦
发表于 2010-12-25 13:15:21 | 显示全部楼层
学习,学习!
发表于 2014-5-6 08:13:37 | 显示全部楼层
雷锋精神传天下!谢谢分享!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 17:35 , Processed in 0.102275 second(s), 29 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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