难点来了,在ListView表格里能否加入添加,查看,删除按钮(基本解决)
本帖最后由 qsy666888 于 2018-4-1 13:53 编辑难点来了,在ListView表格里能否加入添加,查看,删除按钮,论坛里好像没有类似的贴子。
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiListView.au3>
#Include <GuiTreeView.au3>
#Region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Form1", 615, 353, 458, 204)
Global $Group1 = GUICtrlCreateGroup("统计表信息框", 8, 8, 601, 337)
Global $ListView1 = GUICtrlCreateListView("序号|文件名|责任者|起始时间|终止时间|电子文件", 16, 24, 506, 310)
GUICtrlSetBkColor(-1, $CLR_MONEYGREEN);0xC0C0C0)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_SetColumn($ListView1, 0, "序号", 40, -1)
_GUICtrlListView_SetColumn($ListView1, 1, "文件名", 100, -1)
_GUICtrlListView_SetColumn($ListView1, 2, "责任者", 60, -1)
_GUICtrlListView_SetColumn($ListView1, 3, "起始时间", 100, -1)
_GUICtrlListView_SetColumn($ListView1, 4, "终止时间", 100, -1)
_GUICtrlListView_SetColumn($ListView1, 5, "电子文件", 100, -1)
Global $Button1 = GUICtrlCreateButton("添加", 528, 32, 75, 25)
Global $Button2 = GUICtrlCreateButton("删除", 528, 64, 75, 25)
Global $Button3 = GUICtrlCreateButton("更新", 528, 96, 75, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
本帖最后由 kk_lee69 于 2018-3-19 21:12 编辑
回复 1# qsy666888
LISTVIEW 可以原地編輯 加入 INPUT框也可以 加入COMBO
所以 要加入你說的理論上應該是可以只是 工程告大而已
所以你提出這個想法的時候 一堆人告訴你 工程浩大
回复 2# kk_lee69
或者有没有这方面的事例,借鉴一下,谢谢你的回复 回复 3# qsy666888
http://www.autoit3.cn/search.php?searchid=7&orderby=lastpost&ascdesc=desc&searchsubmit=yes
http://www.autoit3.cn/forum.php?mod=viewthread&tid=15531&highlight=%D4%AD%B5%D8%B1%E0%BC%AD 本帖最后由 kk_lee69 于 2018-3-20 09:17 编辑
回复 3# qsy666888
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
_Main()
Func _Main()
Local $hGui, $listview, $hImage
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$hGui = GUICreate("ImageList: Icon hinzufugen", 400, 300)
$listview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUISetState()
; Ladt die Bilder
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage, @ScriptDir & "\r-icon.ico",0)
_GUIImageList_AddIcon($hImage, @ScriptDir & "\s_icon.ico",0)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 165)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
; Fugt die Spalten hinzu
_GUICtrlListView_AddColumn($listview, "Spalte 1", 120)
_GUICtrlListView_AddColumn($listview, "Spalte 2", 120)
_GUICtrlListView_AddColumn($listview, "Spalte 3", 120)
; Fugt die Items hinzu
_GUICtrlListView_AddItem($listview, "Zeile 1: Spalte 1", 0)
_GUICtrlListView_AddSubItem($listview, 0, "Zeile 1: Spalte 2", 1, 1)
_GUICtrlListView_AddSubItem($listview, 0, "Zeile 1: Spalte 3", 2, 2)
_GUICtrlListView_AddItem($listview, "Zeile 2: Spalte 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Zeile 2: Spalte 2", 1, 2)
_GUICtrlListView_AddItem($listview, "Zeile 3: Spalte 1", 2)
_GUICtrlListView_AddItem($listview, "Zeile 4: Spalte 1", 3)
_GUICtrlListView_AddItem($listview, "Zeile 5: Spalte 1", 4)
_GUICtrlListView_AddSubItem($listview, 4, "Zeile 5: Spalte 2", 1, 3)
_GUICtrlListView_AddItem($listview, "Zeile 6: Spalte 1", 5)
_GUICtrlListView_AddSubItem($listview, 5, "Zeile 6: Spalte 2", 1, 4)
_GUICtrlListView_AddSubItem($listview, 5, "Zeile 6: Spalte 3", 2, 3)
; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslost
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
EndFunc ;==>_Main
回复 3# qsy666888
回复 6# kk_lee69
大侠,你太厉害了,代码能发来参考一下吗? 回复 7# qsy666888
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
Local $hGui, $listview, $hImage
Local $exStyles = BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)
$hGui = GUICreate("ImageList: Icon hinzufugen", 400, 300)
$listview = _GUICtrlListView_Create($hGui, "", 2, 2, 394, 268, BitOR($LVS_SHOWSELALWAYS, $LVS_NOSORTHEADER, $LVS_REPORT))
_GUICtrlListView_SetExtendedListViewStyle($listview, $exStyles)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState()
; Ladt die Bilder
$hImage = _GUIImageList_Create(16, 16, 5, 3)
_GUIImageList_AddIcon($hImage,"C:\Users\WORKA\Pictures\0\C1.ico",0)
_GUIImageList_AddIcon($hImage, "C:\Users\WORKA\Pictures\0\C2.ico",0)
_GUIImageList_AddIcon($hImage, "C:\Users\WORKA\Pictures\0\C3.ico", 0)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 168)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 137)
_GUIImageList_AddIcon($hImage, @SystemDir & "\shell32.dll", 146)
_GUICtrlListView_SetImageList($listview, $hImage, 1)
; Fugt die Spalten hinzu
_GUICtrlListView_AddColumn($listview, "Spalte 1", 120)
_GUICtrlListView_AddColumn($listview, "Spalte 2", 120)
_GUICtrlListView_AddColumn($listview, "Spalte 3", 120)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
_GUICtrlListView_AddColumn($listview, "", 16)
; Fugt die Items hinzu
_GUICtrlListView_AddItem($listview, "Zeile 1: Spalte 1", 0)
_GUICtrlListView_AddSubItem($listview, 0, "Zeile 1: Spalte 2", 1, 1)
_GUICtrlListView_AddSubItem($listview, 0, "Zeile 1: Spalte 3", 2, 2)
_GUICtrlListView_AddItem($listview, "Zeile 2: Spalte 1", 1)
_GUICtrlListView_AddSubItem($listview, 1, "Zeile 2: Spalte 2", 1, 2)
_GUICtrlListView_AddItem($listview, "Zeile 3: Spalte 1", 2)
_GUICtrlListView_AddItem($listview, "Zeile 4: Spalte 1", 3)
_GUICtrlListView_AddItem($listview, "Zeile 5: Spalte 1", 4)
_GUICtrlListView_AddSubItem($listview, 4, "Zeile 5: Spalte 2", 1, 3)
_GUICtrlListView_AddItem($listview, "Zeile 6: Spalte 1", 5)
_GUICtrlListView_AddSubItem($listview, 5, "Zeile 6: Spalte 2", 1, 4)
_GUICtrlListView_AddSubItem($listview, 5, "Zeile 6: Spalte 3", 2, 3)
_GUICtrlListView_AddSubItem($listview, 0, "", 3,0)
_GUICtrlListView_AddSubItem($listview, 0, "", 4,1)
_GUICtrlListView_AddSubItem($listview, 0, "", 5,2)
; Die Schleife wiederholt sich, bis der Benutzer die Beenden-Aktion der GUI auslost
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $iCode
Case $NM_CLICK;??
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$iSub = DllStructGetData($tInfo, "SubItem")
IF$iIndex=0 AND $iSub=3 Then
ConsoleWrite("你點了+"&@CRLF)
MsgBox(0,"","你點了+")
ElseIf $iIndex=0 AND $iSub=4 Then
MsgBox(0,"","你點了搜尋")
ElseIf $iIndex=0 AND $iSub=5 Then
MsgBox(0,"","你點了停止")
EndIf
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
回复 8# kk_lee69
感谢 感谢 论坛万岁论坛万岁 回复 8# kk_lee69
能把首列的图标取消掉吗,我没有找到取消的代码
回复 11# qsy666888
你指的是 空白 還是真的圖標??
真的圖標示 可以拿掉的 但是 那個位置會有空白的一塊 圖標大小 是無法拿掉的
解決方法是 對調 把 0基 往後換位置 換到後面去 回复 12# kk_lee69
只要序号那一列不显示图标出来,空白的也行 回复 12# kk_lee69
不行哈,我怎么弄序号那一列都有图标 本帖最后由 kk_lee69 于 2018-3-27 09:56 编辑
回复 14# qsy666888
方法一
給個 不存在的 圖標編號不就得了
方法二 圖標顯示在 第一列 然後 利用 _GUICtrlListView_SetColumnOrder調換順序
http://www.autoit3.cn/attachments/month_1104/1104300005afc48a7cd62a3c31.jpg
页:
[1]