joydog 发表于 2008-10-6 16:22:13

如何使GUICtrlCreateListView 默认选中某行

#include <GUIConstants.au3>
#include <GuiListView.au3>
Opt("TrayIconHide", 1)
GUICreate("程序", 350, 70, -1, -1)
$a= GUICtrlCreateButton("打印", 300, 10, 50, 50)
$List = GuiCtrlCreateListview("IC卡号|姓名|身份证号", 0, 0, 300, 70)
GuiCtrlCreateListViewItem("11111|aaa|bbbjhjhjhjhjhjh",$list)
GuiCtrlCreateListViewItem("2222|bbb|ddd",$list )
GuiCtrlCreateListViewItem("3333|bbb|ddd",$list )
GuiCtrlCreateListViewItem("4444|bbb|ddd",$list )
GuiCtrlCreateListViewItem("5555|bbb|ddd",$list )

_GUICtrlListView_SetItemChecked($List,4,true)
GUISetState(); display the GUI

Do
        $msg = GUIGetMsg()
        Select

                Case $msg= $a
                  $dd="鼠标选中:"&_GUICtrlListViewGetItemText($List, _GUICtrlListViewGetSelectedIndices($List))
                     msgbox(0,"",_GUICtrlListView_GetSelectedCount($list))
                  MsgBox(0, "", $dd)
               exit
        EndSelect

Until $msg = $GUI_EVENT_CLOSE



我想默认选择第四行...可是直接按打印 会发现没有选中任何一行

[ 本帖最后由 joydog 于 2008-10-6 17:45 编辑 ]

rolaka 发表于 2008-10-6 17:17:02

GUICtrlSetData ( 控件ID, 数据 [, 默认值] )...

sanhen 发表于 2008-10-6 17:28:17

3.2.13.7测试通过。


#include <GUIConstants.au3>
#include <GuiListView.au3>
Opt("TrayIconHide", 1)
GUICreate("程序", 350, 70, -1, -1)
$a= GUICtrlCreateButton("打印", 300, 10, 50, 50)
$List = GuiCtrlCreateListview("IC卡号|姓名|身份证号", 0, 0, 300, 70)
GuiCtrlCreateListViewItem("11111|aaa|bbbjhjhjhjhjhjh",$list)
GuiCtrlCreateListViewItem("2222|bbb|ddd",$list )
GuiCtrlCreateListViewItem("3333|bbb|ddd",$list )
GuiCtrlCreateListViewItem("4444|bbb|ddd",$list )
GuiCtrlCreateListViewItem("5555|bbb|ddd",$list )

_GUICtrlListView_SetItemSelected($List, 4)
GUISetState(); display the GUI

Do
      $msg = GUIGetMsg()
      Select

                Case $msg= $a
                  $dd="鼠标选中:"&_GUICtrlListView_GetItemText($List, Int(_GUICtrlListView_GetSelectedIndices($List)))
                     msgbox(0,"",_GUICtrlListView_GetSelectedCount($list))
                  MsgBox(0, "", $dd)
               ;exit
      EndSelect

Until $msg = $GUI_EVENT_CLOSE

joydog 发表于 2008-10-6 17:45:27

居士呀...你就是我的神!!!!

哈哈..搞定了

qq342252004 发表于 2009-10-8 10:30:31

学习了........

foolbyrd 发表于 2009-10-14 07:45:08

留个脚印,以备后用。

RobertLi 发表于 2009-10-14 10:04:46

_GUICtrlListView_SetItemChecked($List,4,true)
页: [1]
查看完整版本: 如何使GUICtrlCreateListView 默认选中某行