找回密码
 加入
搜索
查看: 1333|回复: 6

为何取不到当前选择的list的值

[复制链接]
发表于 2010-6-8 20:44:35 | 显示全部楼层 |阅读模式
本帖最后由 Joo 于 2010-6-8 21:05 编辑
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

$Form1 = GUICreate("Organizer", 633, 454, 193, 115)
$List1 = GUICtrlCreateListview("NO.|Name|Sex|Tel|E-mail|Address", 16, 8, 593, 98)
GUICtrlCreateListViewItem("1|Li|Male|138|xyz@qq.com|China",$List1)
$Button1 = GUICtrlCreateButton("OK", 504, 120, 105, 33, 0)
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

Select
        Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        case $msg=$Button1
                $var=StringSplit(GUICtrlRead($List1),"|",0)
                MsgBox(0,"",$var[0]);
EndSelect
WEnd
$var[0]=1
为何取不到我选择的list的值,是哪里有问题么?

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

 楼主| 发表于 2010-6-8 20:49:40 | 显示全部楼层
我要是想 用$var[2]的值"Li" 的话 就会报错
发表于 2010-6-8 20:57:26 | 显示全部楼层
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>

$Form1 = GUICreate("Organizer", 633, 454, 193, 115)
$List1 = GUICtrlCreateListview("NO.|Name|Sex|Tel|E-mail|Address", 16, 8, 593, 98)
GUICtrlCreateListViewItem("1|Li|Male|138|xyz@qq.com|China",$List1)
$Button1 = GUICtrlCreateButton("OK", 504, 120, 105, 33, 0)
GUISetState(@SW_SHOW)

While 1
  $msg = GUIGetMsg()

Select
        Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
        case $msg=$Button1
                $var=StringSplit(GUICtrlRead(GUICtrlRead($List1)),"|",0)
                MsgBox(0,"",$var[0]);
EndSelect
WEnd

评分

参与人数 1金钱 +10 收起 理由
Joo + 10

查看全部评分

发表于 2010-6-8 20:58:54 | 显示全部楼层
GUICtrlRead($List1) 这里返回的是控件Id~
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>

$Form1 = GUICreate("Organizer", 633, 454, 193, 115)
$List1 = GUICtrlCreateListView("NO.|Name|Sex|Tel|E-mail|Address", 16, 8, 593, 98)
GUICtrlCreateListViewItem("1|Li|Male|138|xyz@qq.com|China", $List1)
$Button1 = GUICtrlCreateButton("OK", 504, 120, 105, 33, 0)
GUISetState(@SW_SHOW)

While 1
        $msg = GUIGetMsg()
        Select
                Case $msg = $GUI_EVENT_CLOSE
                        ExitLoop
                Case $msg = $Button1
                        $var = _GUICtrlListView_GetItemTextArray($List1) ;返回数组
                        MsgBox(0, "", $var[2])
        EndSelect
WEnd

评分

参与人数 1金钱 +20 收起 理由
Joo + 20 非常感谢!!!

查看全部评分

 楼主| 发表于 2010-6-8 21:00:26 | 显示全部楼层
回复 3# kxing


    谢谢谢谢!!!
 楼主| 发表于 2010-6-8 21:01:44 | 显示全部楼层
回复 3# kxing


    谢谢谢谢!!!
    但是为何要调用两次 那个函数?
 楼主| 发表于 2010-6-8 21:05:17 | 显示全部楼层
回复 4# afan


    谢谢谢谢,明白了!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-6 12:27 , Processed in 0.095407 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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