找回密码
 加入
搜索
查看: 8779|回复: 11

[GUI管理] ListViewItem数据修改问题【已解决】

 火.. [复制链接]
发表于 2011-8-3 18:47:22 | 显示全部楼层 |阅读模式
本帖最后由 sliqi 于 2011-8-3 19:21 编辑



如图,如何只修改 项1里存在 123 修改成ABC呢。求方法。求思路

附例子代码:=====
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


   Dim $listview, $button, $item1, $item2, $item3, $input1, $msg,$from,$list
    $from = GUICreate("listview", 220, 250)

    $listview = GUICtrlCreateListView("列 1 |列 2|列 3  ", 10, 10, 200, 150)

    $item1 = GUICtrlCreateListViewItem("项1|子项1|123", $listview)
    $item3 = GUICtrlCreateListViewItem("项2|子项2|456", $listview)
        $item4 = GUICtrlCreateListViewItem("项3|子项3|789", $listview)
        
        $button = GUICtrlCreateButton("123修改成abc", 40, 170, 120, 20)
    GUISetState()


    Do
        $msg = GUIGetMsg()
        
        Select
                        Case $msg = $button
                                
        $list = ControlListView($from, "" , $listview , "FindItem" , "123" , 1 ) ;;不知道怎么写 ControlListView 求方法
IF $list <> - 1 THEN 
        MsgBox(0, "listview item",11111, 2)
ENDIF 
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE

本帖子中包含更多资源

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

×
发表于 2011-8-3 18:57:40 | 显示全部楼层
回复 1# sliqi

@sliqi:
读你的问题感觉有“歧义”?是只修改已知序号的项目的子项数值,

还是历遍全表中column3中含有 “123”的项目并修改为 “ABC”?
 楼主| 发表于 2011-8-3 19:03:54 | 显示全部楼层
不历遍全表中column3,先检索 列1 存在 项1 ,则修改123
发表于 2011-8-3 19:07:34 | 显示全部楼层
回复 3# sliqi

呵呵,你把我说糊涂了,你这不就成了取子项数据了吗?
 楼主| 发表于 2011-8-3 19:14:29 | 显示全部楼层
可有方法实现修改?
发表于 2011-8-3 19:16:37 | 显示全部楼层
本帖最后由 powerofos 于 2011-8-3 19:17 编辑
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>


   Dim $listview, $button, $item1, $item2, $item3, $input1, $msg,$from,$list
    $from = GUICreate("listview", 220, 250)

    $listview = GUICtrlCreateListView("列 1 |列 2|列 3  ", 10, 10, 200, 150)

    $item1 = GUICtrlCreateListViewItem("项1|子项1|123", $listview)
    $item3 = GUICtrlCreateListViewItem("项2|子项2|456", $listview)
        $item4 = GUICtrlCreateListViewItem("项3|子项3|789", $listview)
        
        $button = GUICtrlCreateButton("123修改成abc", 40, 170, 120, 20)
    GUISetState()


    Do
        $msg = GUIGetMsg()
        
        Select
                        Case $msg = $button
;~                                 Local $iText = _GUICtrlListView_GetItemTextArray($listview,0); 基于0 的项目序号
;~                                 If $iText[0] = 3 Then
                                        _GUICtrlListView_SetItemText($ListView, 0, "ABC", 2)                                           
;~                                 EndIf                
                                


                                
                                
                EndSelect                
    
        
        
        Until $msg = $GUI_EVENT_CLOSE
回复 5# sliqi




多看帮助........
 楼主| 发表于 2011-8-3 19:20:24 | 显示全部楼层
哎,很少看UDF。谢谢了。
我还奇怪_GUICtrlListView_SetItemText 无法修改后面的数据

我也刚找到_GUICtrlListView_GetItemTextArray研究,呵呵
发表于 2011-8-3 19:30:47 | 显示全部楼层
本帖最后由 水木子 于 2011-8-3 19:31 编辑

回复 7# sliqi


条条道路通罗马!

GUICreate('listview', 220, 250)

$Listview = GUICtrlCreateListView('列 1 |列 2|列 3  ', 10, 10, 200, 150)
$iItem1 = GUICtrlCreateListViewItem('项1|子项1|123', $Listview)
$iItem3 = GUICtrlCreateListViewItem('项2|子项2|456', $Listview)
$iItem4 = GUICtrlCreateListViewItem('项3|子项3|789', $Listview)

$button = GUICtrlCreateButton('123修改成abc', 40, 170, 120, 20)
GUISetState()


While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case -3
                        Exit
                Case $button
                        GUICtrlSetData($iItem1, '||ABC')
        EndSwitch
WEnd

评分

参与人数 1金钱 +10 收起 理由
35888894 + 10 条条大路通罗马

查看全部评分

发表于 2011-8-3 19:32:58 | 显示全部楼层
本帖最后由 powerofos 于 2011-8-3 19:34 编辑

如果你发问时直接地说明白了:如何修改指定项目的指定子项目数据,那么这个问题,估计大侠们不想鸟你,

我是觉得你可能要遍历列表中COLUMN 3中的“123”,并将之改为“ABC”,才多口问了句。
发表于 2011-8-3 19:36:01 | 显示全部楼层
回复 9# powerofos

有道理!
 楼主| 发表于 2011-8-3 19:38:58 | 显示全部楼层
哥,我的意思是检索所有的ListViewITem中如果有 项1 则修改123为ABC
 楼主| 发表于 2011-8-3 19:42:40 | 显示全部楼层
回复 9# powerofos

;=====================================
    补充: 由于listviewitem表随时更新,项1会在100行中排列在任何一行,我想是检索整个Listview里
找到项1就修改它的子值,
发表于 2011-8-3 19:50:51 | 显示全部楼层
回复 12# sliqi


for $i = 0 to 项目数-1
    _GUICtrlListView_FindInText    ;指定检索字符
   _GUICtrlListView_GetItemTextArray  ;检查上函数返回的ID,如果符合的却是列3的数据, 则执行相应function,否则继续。
若_GUICtrlListView_FindInText    函数返回“到底”的信息,则退出循环
next
发表于 2011-8-3 20:19:03 | 显示全部楼层
回复 12# sliqi
随时更新?
从数据源上修改
 楼主| 发表于 2011-8-4 00:13:28 | 显示全部楼层
回复 14# 3mile

3mile兄,请看代码
    ;;;;========================================
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


   Dim $listview, $button, $item1, $item2, $item3, $input1, $msg,$from,$list
    $from = GUICreate("listview", 220, 250)

    $listview = GUICtrlCreateListView("列 1 |列 2|列 3  ", 10, 10, 200, 150)

    $item1 = GUICtrlCreateListViewItem("项1|子项1|123", $listview)
    $item3 = GUICtrlCreateListViewItem("项2|子项2|456", $listview)
        $item4 = GUICtrlCreateListViewItem("项3|子项3|789", $listview)
       
        $button = GUICtrlCreateButton("123修改成abc", 40, 170, 120, 20)
    GUISetState()


    Do
        $msg = GUIGetMsg()
        
        Select
                        Case $msg = $button
$list = ControlListView($from, "" , $listview , "FindItem" , "123" , 2)
IF $list <> - 1 THEN
        MsgBox(0, "listview",11111, 2)
;;;;;   ControlSetText  有问题无法把123修改成abc
        ControlSetText($listview, $list, "abc", 0);;;  123 替换成 abc
       
ENDIF

       
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-11 13:34 , Processed in 0.110908 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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