Joo 发表于 2010-6-8 20:44:35

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

本帖最后由 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);
EndSelect
WEnd$var=1
为何取不到我选择的list的值,是哪里有问题么?

Joo 发表于 2010-6-8 20:49:40

我要是想 用$var的值"Li" 的话 就会报错

kxing 发表于 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);
EndSelect
WEnd

afan 发表于 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)
        EndSelect
WEnd

Joo 发表于 2010-6-8 21:00:26

回复 3# kxing


    谢谢谢谢!!!

Joo 发表于 2010-6-8 21:01:44

回复 3# kxing


    谢谢谢谢!!!
    但是为何要调用两次 那个函数?

Joo 发表于 2010-6-8 21:05:17

回复 4# afan


    谢谢谢谢,明白了!
页: [1]
查看完整版本: 为何取不到当前选择的list的值