找回密码
 加入
搜索
查看: 3256|回复: 3

[GUI管理] [已解决]List右键删除,并写入文本的相关问题

[复制链接]
发表于 2010-2-18 17:43:01 | 显示全部楼层 |阅读模式
本帖最后由 xlcwxl 于 2010-4-13 08:29 编辑
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 435, 447, 191, 124)
$Label1 = GUICtrlCreateLabel("任务列表", 8, 8, 52, 17)
$list = GUICtrlCreateList("", 8, 24, 417, 153) 
$RightMenu = GUICtrlCreateContextMenu($list)
$RightDel = GUICtrlCreateMenuItem("删除",$RightMenu)
$Tab1 = GUICtrlCreateTab(8, 184, 417, 169)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("运行程序")
$Label2 = GUICtrlCreateLabel("运行程序", 16, 216, 52, 17)
$Combo1 = GUICtrlCreateCombo("Combo1", 72, 216, 145, 25)
$Button1 = GUICtrlCreateButton("浏览", 224, 216, 75, 25)
$Label3 = GUICtrlCreateLabel("运行参数", 16, 240, 52, 17)
$Input1 = GUICtrlCreateInput("Input1", 72, 240, 145, 21)
$Button2 = GUICtrlCreateButton("写入", 16, 288, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit                        
Case $Button1
$chengxu = GUICtrlRead($Combo1)
$canshu = GUICtrlRead($Input1)
If $chengxu <> '' Then
GUICtrlSetData($list,'"'&$chengxu&' '&$canshu&'"')
Else
MsgBox(64,'提示','你没有选择要运行的程序')
EndIf
EndSwitch
WEnd
1.怎样获取选中的条目并删除?
2.将list种所有条目写入文本中?

感谢:nmgwddj
答案在4楼
发表于 2010-2-18 19:09:53 | 显示全部楼层
_GUICtrlListBox_GetSelItemsText
发表于 2010-4-12 14:09:53 | 显示全部楼层
_GUICtrlListBox_GetSelItems($list)
发表于 2010-4-12 14:24:39 | 显示全部楼层
本帖最后由 nmgwddj 于 2010-4-12 14:46 编辑
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListBox.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 435, 447, 191, 124)
$Label1 = GUICtrlCreateLabel("任务列表", 8, 8, 52, 17)
$list = GUICtrlCreateList("", 8, 24, 417, 153)
$RightMenu = GUICtrlCreateContextMenu($list)
$RightDel = GUICtrlCreateMenuItem("删除", $RightMenu)
$Tab1 = GUICtrlCreateTab(8, 184, 417, 169)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH + $GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("运行程序")
$Label2 = GUICtrlCreateLabel("运行程序", 16, 216, 52, 17)
$Combo1 = GUICtrlCreateCombo("Combo1", 72, 216, 145, 25)
$Button1 = GUICtrlCreateButton("浏览", 224, 216, 75, 25)
$Label3 = GUICtrlCreateLabel("运行参数", 16, 240, 52, 17)
$Input1 = GUICtrlCreateInput("Input1", 72, 240, 145, 21)
$Button2 = GUICtrlCreateButton("删除下试试", 16, 288, 75, 25)
$Button3 = GUICtrlCreateButton("记录信息", 100, 288, 75, 25)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
$chengxu = GUICtrlRead($Combo1)
$canshu = GUICtrlRead($Input1)
For $o = 1 To 10
        GUICtrlSetData($list, '"' & $chengxu + $o        & ' ' & $canshu + $o & '"')
Next
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        If $chengxu <> '' Then
                                GUICtrlSetData($list, '"' & $chengxu & ' ' & $canshu & '"')
                        Else
                                MsgBox(64, '提示', '你没有选择要运行的程序')
                        EndIf
                Case $Button2
                        del()
                Case $Button3
                        Rdlist()
        EndSwitch
WEnd

Func del()
        $i = _GUICtrlListBox_GetCurSel($list)
        If $i = -1 Then
                MsgBox(0, '', '未选择')
                Return
        EndIf
        _GUICtrlListBox_DeleteString($list, $i)
EndFunc   ;==>Del

Func Rdlist()
        Local $a
        $RD = _GUICtrlListBox_GetCount($list)
        For $i = 0 To $RD - 1
                $a &= _GUICtrlListBox_GetText($list, $i) & @LF
        Next
        MsgBox(0, '', $a)
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-18 12:42 , Processed in 0.082318 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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