找回密码
 加入
搜索
查看: 5993|回复: 13

[GUI管理] listview 選定項目問題...防呆措施...求防呆思路

  [复制链接]
发表于 2012-2-23 23:19:53 | 显示全部楼层 |阅读模式
本帖最后由 kk_lee69 于 2012-2-23 23:53 编辑

我做了一個 兩個 LISTVIE 的畫面  如下圖......但是問題來了......有幾個防呆問題我無法解決......



當你選定了 左手邊的 某個項目......... 這時候 使用者 突然後按了 右手邊的 LISTVIEW 畫面後.........整個畫面會變成........



也就是說 使用者可能會以為......右手邊的畫面 並沒有被選擇......但是 這時候 他按下 加入................程式也可以把剛剛選定的加入進去.................如下圖



另外一種情況是 如下圖.....使者者....本來選了一個 後來不想要了....於是在紅色圈圈的地方按一下.....整個畫面就會變成 下面的圖案......這時候 加入 一樣有作用



能夠解決這個防呆問題嗎??  我的目的是 要把系統鎖的更嚴格...... 也就是說使用者 不是 選了 左手邊的畫面 馬上案加入.....我就打算讓 他重新選擇.....能做到嗎??

代碼很長.....所以我挑重點 秀出來.....其實我寫的很基本而已....所以才在想是不是有更好的防呆方式......

$listview1 = GUICtrlCreateListView("編號 (清單)|客戶簡稱  (清單) ", 200, 70, 250, 250,$lvs_report)
$listview2 = GUICtrlCreateListView("編號 (顯示)|客戶簡稱 (在報表顯示)  ", 540, 70, 250, 250,$lvs_report)



加入的 語法


                Case $add1
                        GuiSetState(@SW_DISABLE,$WinMain) ; 禁用視窗,以防用戶作出其他更改

                        
                        $ItemList = _GUICtrlListView_GetSelectedIndices($ListView1,True)
                        _ArrayDisplay($ItemList)
                        ;MsgBox(0,"",_GUICtrlListView_GetSelectedIndices($ListView1))
                        ;Exit
                        
                        ;$ChID=StringLeft(GUICtrlRead(GUICtrlRead($ListView1)),StringInStr(GUICtrlRead(GUICtrlRead($ListView1)),"|")-1)

                        IF $ItemList[0]=0 Then
                                MsgBox(0,"操作錯誤","請於左邊通報清單中選擇  要加入的紀錄",2)
                                $Check1="1"
                        EndIf
                        
                        If $Check1="0" Then
                                        FOR $i=1 TO $ItemList[0] Step 1
                                                $LISTA=_GUICtrlListView_GetItemTextString($ListView1,$ItemList[$i])
                                                
                                                If StringInStr($ProdSTR,StringLeft($LISTA,StringInStr($LISTA,"|",0,1)-1),0,1)=0 Then
                                                        $ProdSTR = $ProdSTR&":"&StringLeft($LISTA,StringInStr($LISTA,"|",0,1)-1)
                                                        ;MsgBox(0,"",$ProdSTR)
                                                        GUICtrlCreateListViewItem($LISTA, $listview2)
                                                        _GUICtrlListView_DeleteItem($ListView1,$ItemList[$i])
                                                Else
                                                        MsgBox(0,"錯誤","產品已經在報表清單中",1)
                                                EndIf
                                        Next
                                
                                
                                ;MsgBox(0,"A",GUICtrlRead(GUICtrlRead($ListView5)))
                                ;GUICtrlCreateListViewItem(GUICtrlRead(GUICtrlRead($ListView1)), $listview2)
                                ;_GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($listview1))
                                ;$CustSTR=$CustSTR&"CustID='"&$ChID&"' or "
                                ;MsgBox(0,"A",$CustSTR)
                        EndIf

                        $Check1 = "0"

                        WinActivate($WinMain,"") 
                        GuiSetState(@SW_ENABLE,$WinMain) ; 使窗口重新可用

本帖子中包含更多资源

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

×
发表于 2012-2-23 23:37:04 | 显示全部楼层
谁知道你是怎么加入的
 楼主| 发表于 2012-2-23 23:54:28 | 显示全部楼层
回复 2# afan


    代碼很長.....所以我挑重點 秀出來.....其實我寫的很基本而已....所以才在想是不是有更好的防呆方式......

$listview1 = GUICtrlCreateListView("編號 (清單)|客戶簡稱  (清單) ", 200, 70, 250, 250,$lvs_report)
$listview2 = GUICtrlCreateListView("編號 (顯示)|客戶簡稱 (在報表顯示)  ", 540, 70, 250, 250,$lvs_report)



加入的 語法


                Case $add1
                        GuiSetState(@SW_DISABLE,$WinMain) ; 禁用視窗,以防用戶作出其他更改

                        
                        $ItemList = _GUICtrlListView_GetSelectedIndices($ListView1,True)
                        _ArrayDisplay($ItemList)
                        ;MsgBox(0,"",_GUICtrlListView_GetSelectedIndices($ListView1))
                        ;Exit
                        
                        ;$ChID=StringLeft(GUICtrlRead(GUICtrlRead($ListView1)),StringInStr(GUICtrlRead(GUICtrlRead($ListView1)),"|")-1)

                        IF $ItemList[0]=0 Then
                                MsgBox(0,"操作錯誤","請於左邊通報清單中選擇  要加入的紀錄",2)
                                $Check1="1"
                        EndIf
                        
                        If $Check1="0" Then
                                        FOR $i=1 TO $ItemList[0] Step 1
                                                $LISTA=_GUICtrlListView_GetItemTextString($ListView1,$ItemList[$i])
                                                
                                                If StringInStr($ProdSTR,StringLeft($LISTA,StringInStr($LISTA,"|",0,1)-1),0,1)=0 Then
                                                        $ProdSTR = $ProdSTR&":"&StringLeft($LISTA,StringInStr($LISTA,"|",0,1)-1)
                                                        ;MsgBox(0,"",$ProdSTR)
                                                        GUICtrlCreateListViewItem($LISTA, $listview2)
                                                        _GUICtrlListView_DeleteItem($ListView1,$ItemList[$i])
                                                Else
                                                        MsgBox(0,"錯誤","產品已經在報表清單中",1)
                                                EndIf
                                        Next
                                
                                
                                ;MsgBox(0,"A",GUICtrlRead(GUICtrlRead($ListView5)))
                                ;GUICtrlCreateListViewItem(GUICtrlRead(GUICtrlRead($ListView1)), $listview2)
                                ;_GUICtrlListView_DeleteItemsSelected(GUICtrlGetHandle($listview1))
                                ;$CustSTR=$CustSTR&"CustID='"&$ChID&"' or "
                                ;MsgBox(0,"A",$CustSTR)
                        EndIf

                        $Check1 = "0"

                        WinActivate($WinMain,"") 
                        GuiSetState(@SW_ENABLE,$WinMain) ; 使窗口重新可用
发表于 2012-2-24 00:08:17 | 显示全部楼层
_GUICtrlListView_CopyItems()
发表于 2012-2-24 00:16:00 | 显示全部楼层
另外,第二个图问题源于你的样式缺少 $LVS_SHOWSELALWAYS
GUICtrlCreateListView("編號 (清單)|客戶簡稱  (清單) ", 200, 70, 250, 250, $LVS_REPORT + $LVS_SHOWSELALWAYS)

评分

参与人数 1金钱 +10 收起 理由
zch11230 + 10 真牛

查看全部评分

发表于 2012-2-24 01:12:45 | 显示全部楼层
afan居然看明白lz问什么了,佩服

评分

参与人数 1金钱 +10 收起 理由
afan + 10 :)

查看全部评分

发表于 2012-2-24 01:18:37 | 显示全部楼层
确实 有这个问题,没有深入研究,等答案..学习..
发表于 2012-2-24 01:29:39 | 显示全部楼层
afan居然看明白lz问什么了,佩服
netegg 发表于 2012-2-24 01:12



    “這時候 使用者 突然後按了 右手邊的 LISTVIEW 畫面後” 这句话看得我眼前瞬间有了 迅雷不及掩耳盗铃 的画面
 楼主| 发表于 2012-2-24 01:46:47 | 显示全部楼层
回复 8# afan
    表達的不好  請多見諒.....順便在請問一下.....有人 LISTVIEW  可以做到 兩個 不同的 LISTVIEW  使用拖曳的方式 移動到 另外一個表嗎??
发表于 2012-2-24 06:21:09 | 显示全部楼层
回复 9# kk_lee69
列表互换还是仅数据转移
发表于 2012-2-24 17:52:17 | 显示全部楼层
都是繁体字哦。
 楼主| 发表于 2012-2-24 22:28:25 | 显示全部楼层
回复 10# netegg
都可以 我的用意 很簡單.....讓使用者方便操作....鈀資料從左邊的LISTVIEW 移動到 右邊的.....

等使用者 選擇完畢後......必須要按下 更新 或者其他按鈕......在去讀取 右手邊的LISTVIEW 資料 回寫到資料庫裡面
发表于 2012-2-24 22:43:04 | 显示全部楼层
$item = _guictrllistview_getselect($listleft)
$num = _guictrllistview_getitemcount($listright)
$aItem = _guictrllistview_getitemTextArray($listleft, $item)
_guictrllistview_additem($listright, $aItem[1], $num+1)
_guictrllistview_addsubitem($listright, $num+1, $aItem[2],1)
....
 楼主| 发表于 2012-2-24 22:47:32 | 显示全部楼层
回复 13# netegg

了解 感謝 回覆 我研究看看
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-20 18:52 , Processed in 0.083366 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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