(已解决)listview函数,删除列可以,删除行不行。是不是我英语太差理解错了?
本帖最后由 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
#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
For $iI = 0 To UBound($aItems) - 1
$aItems[$iI] = "Item " & $iI
$aItems[$iI] = "Item " & $iI & "-1"
$aItems[$iI] = "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
_GUICtrlListView_DeleteItem 是删除行
_GUICtrlListView_DeleteColumn 是删除列 回复 2# 298311657
你的是可以的,可是为什么我的代码就是不行啊?
我用的也是_GUICtrlListView_DeleteItem啊 回复 3# yhxhappy
函数我写的应该没错吧?可是为什么删除不了呢? _GUICtrlListView_DeleteItem(GUICtrlGetHandle($ListView1), 1) 回复 6# yhxhappy
果然可以,谢啦 学习,学习! 雷锋精神传天下!谢谢分享!
页:
[1]