找回密码
 加入
搜索
查看: 2138|回复: 14

[网络通信] 难点来了,在ListView表格里能否加入添加,查看,删除按钮(基本解决)

  [复制链接]
发表于 2018-3-19 16:02:55 | 显示全部楼层 |阅读模式
本帖最后由 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2018-3-19 21:07:00 | 显示全部楼层
本帖最后由 kk_lee69 于 2018-3-19 21:12 编辑

回复 1# qsy666888

LISTVIEW 可以原地編輯 加入 INPUT框  也可以 加入COMBO

所以 要加入你說的  理論上應該是可以  只是 工程告大而已

所以你提出這個想法的時候 一堆人告訴你 工程浩大

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
 楼主| 发表于 2018-3-20 08:01:38 | 显示全部楼层
回复 2# kk_lee69

或者有没有这方面的事例,借鉴一下,谢谢你的回复
发表于 2018-3-20 09:01:33 | 显示全部楼层
发表于 2018-3-20 09:14:39 | 显示全部楼层
本帖最后由 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

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2018-3-21 16:38:07 | 显示全部楼层
回复 3# qsy666888

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×

评分

参与人数 1金钱 +10 收起 理由
xyhqqaa + 10 学习了

查看全部评分

 楼主| 发表于 2018-3-21 16:40:02 | 显示全部楼层
回复 6# kk_lee69

大侠,你太厉害了,代码能发来参考一下吗?
发表于 2018-3-21 16:43:01 | 显示全部楼层
回复 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
 楼主| 发表于 2018-3-21 16:45:49 | 显示全部楼层
回复 8# kk_lee69

感谢 感谢
发表于 2018-3-23 11:16:21 | 显示全部楼层
论坛万岁论坛万岁
 楼主| 发表于 2018-3-26 22:41:07 | 显示全部楼层
回复 8# kk_lee69

能把首列的图标取消掉吗,我没有找到取消的代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2018-3-27 01:31:18 | 显示全部楼层
回复 11# qsy666888

你指的是 空白 還是真的圖標??

真的圖標示 可以拿掉的 但是 那個位置會有空白的一塊 圖標大小 是無法拿掉的

解決方法是 對調 把 0基 往後換位置 換到後面去
 楼主| 发表于 2018-3-27 06:56:30 | 显示全部楼层
回复 12# kk_lee69

只要序号那一列不显示图标出来,空白的也行
 楼主| 发表于 2018-3-27 07:03:37 | 显示全部楼层
回复 12# kk_lee69

不行哈,我怎么弄序号那一列都有图标
发表于 2018-3-27 09:47:41 | 显示全部楼层
本帖最后由 kk_lee69 于 2018-3-27 09:56 编辑

回复 14# qsy666888

方法一
給個 不存在的 圖標編號  不就得了


方法二 圖標顯示在 第一列 然後 利用 _GUICtrlListView_SetColumnOrder  調換順序

您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-4-26 23:58 , Processed in 0.080127 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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