找回密码
 加入
搜索
查看: 1486|回复: 1

[AU3基础] 有关GUICtrlCreateListViewItem问题

[复制链接]
发表于 2010-12-24 12:55:14 | 显示全部楼层 |阅读模式
请教如何实现当滑鼠点选在项目1时,资料同时显示在$input1里面,原码如下~~谢谢
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    
    GUICreate("检视清单项目", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF)  ; 将变更背景色彩

    $listview = GUICtrlCreateListView("栏位1  |栏位2|栏位3  ", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
    $button = GUICtrlCreateButton("数值?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("项目2|栏位22|栏位23", $listview)
    $item2 = GUICtrlCreateListViewItem("项目1|栏位12|栏位13", $listview)
    $item3 = GUICtrlCreateListViewItem("项目3|栏位32|栏位33", $listview)
    $input1 = GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)   ; 允许即时拖曳动作
    GUISetState()
    GUICtrlSetData($item2, "|“项目1”")
    GUICtrlSetData($item3, "||“栏位33”")
    GUICtrlDelete($item1)

    Do
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $button
                MsgBox(0, "检视清单项目", GUICtrlRead(GUICtrlRead($listview)), 2)
            Case $msg = $listview
                MsgBox(0, "检视清单", "已点选=" & GUICtrlGetState($listview), 2)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example
 楼主| 发表于 2010-12-25 13:55:17 | 显示全部楼层
暂时想到个方法解决,但还是有点小问题,虽然选择项目后,再$input1会即时显示项目的内容,但会变成$input1无法变更资料,还需要想其法办法解决,源码如下
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $listview, $button, $item1, $item2, $item3, $input1, $msg
    
    GUICreate("检视清单项目", 220, 250, 100, 200, -1, $WS_EX_ACCEPTFILES)
    GUISetBkColor(0x00E0FFFF)  ; 将变更背景色彩

    $listview = GUICtrlCreateListView("栏位1  |栏位2|栏位3  ", 10, 10, 200, 150);,$LVS_SORTDESCENDING)
    $button = GUICtrlCreateButton("数值?", 75, 170, 70, 20)
    $item1 = GUICtrlCreateListViewItem("项目2|栏位22|栏位23", $listview)
    $item2 = GUICtrlCreateListViewItem("项目1|栏位12|栏位13", $listview)
    $item3 = GUICtrlCreateListViewItem("项目3|栏位32|栏位33", $listview)
    $input1 = GUICtrlCreateInput("", 20, 200, 150)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)   ; 允许即时拖曳动作
    GUISetState()
    GUICtrlSetData($item2, "|“项目1”")
    GUICtrlSetData($item3, "||“栏位33”")
    GUICtrlDelete($item1)

    Do
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $button
                MsgBox(0, "检视清单项目", GUICtrlRead(GUICtrlRead($listview)), 2)
                        Case $listview
                                If _GUICtrlListView_GetItemSelected($listview , 0) = "True" Then 
                                        GUICtrlSetData($input1, GUICtrlRead(GUICtrlRead($listview)))
                                Else 
                                        If _GUICtrlListView_GetItemSelected($listview , 1) = "True" Then
                                        GUICtrlSetData($input1, GUICtrlRead(GUICtrlRead($listview)))
                                        EndIf
                                EndIf
            Case $msg = $listview
                MsgBox(0, "检视清单", "已点选=" & GUICtrlGetState($listview), 2)
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc   ;==>Example
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 15:52 , Processed in 0.081270 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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