|
本帖最后由 ybbihsse 于 2011-1-1 12:33 编辑
如图,当程序往ListView1框添数据时,当用户点击了输入框某个位置时,里面的数据就会不能正常里面的数据,鼠标点击里面的项里数据会自动变了
,
如果禁用控件,;~ GUICtrlSetState (-1, $GUI_DISABLE ) ,但控件将变成灰色,滚动条要往上拖动就没办法了拖动了,连滚动条也灰了
-------------------------------------------------------------------------------------------------------------------------------------#include <AccessCOM.au3>
#include <Array.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GUIListView.au3>
#include <GUIConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
;~ Dim $yo
;~ $adSource = @ScriptDir & "\mdb.mdb"
;~ $adTable = "记事本"
;~ ;表中的字段 ID|标题|心情|正文|备注|日期|更新
;~ $adcol = "标题 | 心情 | 正文 | 备注"
;~ $rData = "测试第1个 | 一般 | 测试内容测试内容 | 备注 "
;~ $yo = _accessAddRecord($adSource, $adTable, $rData, $adCol = 0);在DB1.mdb数据库中添加新记录
;~ MsgBox(0, '纪录数', '本表有' & _accessCountRecords($adSource, $adTable) & '条数据记录')
;~ MsgBox(0, "提示", "数据库添加新记录< " & $rData & " >成功")
;Global $GUI_Input1,$GUI_Input2,$GUI_Input34,$GUI_Input35,$GUI_Input136,$GUI_Input37,$GUI_Input38,$GUI_Input39,$GUI_Input40
;Global $GUI_Button,$YS,$GUI_ListBox,$aRow
#Region ### START Koda GUI section ### Form=d:\我的文档\downloads\sqlite操作实例(编译后的程序)\zs.kxf
$Form1_1 = GUICreate("窗体1", 691, 495, 238, 82)
;$GUI_ListBox = GUICtrlCreateListView("",6, 2, 672, 365)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 0, "编号", 60)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 1, "商品代码", 100)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 2 ,"颜色", 100)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 3 ,"34", 50)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 4 ,"35", 50)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 5 ,"36", 50)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 6 ,"37", 50)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 7 ,"38", 50)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 8 ,"39", 50)
;_GUICtrlListView_InsertColumn($GUI_ListBox, 9 ,"40", 50)
Dim $ListView1
Global $mdb_data_path = @ScriptDir & '\Ms.mdb'
Global $tblname="SHOPBILLMX"
Global $mdb_data_pwd
Global $swhere = ""
Global $zdywhere,$RS
Global $checkbutt1 = 1
GUICtrlSendMsg(-1, 0x101E, 0, 50)
GUICtrlCreateGroup("", 7, 367, 672, 107)
GUICtrlCreateLabel("商品代码", 38, 379, 64, 15)
;~ $Input1 = GUICtrlCreateInput("", 55, 35, 41, 21,$ES_NUMBER);本例子只可输入数字
$GUI_Input1 = GUICtrlCreateInput("", 15, 401, 113, 21,$ES_NUMBER)
$GUI_Input2 = GUICtrlCreateInput("", 133, 401, 73, 21,$ES_NUMBER)
$GUI_Input34 = GUICtrlCreateInput("", 211, 401, 41, 21,$ES_NUMBER)
$GUI_Input35 = GUICtrlCreateInput("", 259, 401, 41, 21,$ES_NUMBER)
$GUI_Input36 = GUICtrlCreateInput("", 307, 401, 41, 21,$ES_NUMBER)
$GUI_Input37 = GUICtrlCreateInput("", 355, 401, 41, 21,$ES_NUMBER)
$GUI_Input38 = GUICtrlCreateInput("", 403, 401, 41, 21,$ES_NUMBER)
$GUI_Input39 = GUICtrlCreateInput("", 451, 401, 41, 21,$ES_NUMBER)
$GUI_Input40 = GUICtrlCreateInput("", 499, 401, 41, 21,$ES_NUMBER)
$GUI_Button = GUICtrlCreateButton("写入", 563, 400, 48, 22)
$YS = GUICtrlCreateLabel("颜色", 157, 380, 28, 17)
$Label2 = GUICtrlCreateLabel("34", 221, 380, 16, 17)
$Label3 = GUICtrlCreateLabel("35", 269, 380, 16, 17)
$Label4 = GUICtrlCreateLabel("36", 325, 380, 16, 17)
$Label5 = GUICtrlCreateLabel("37", 365, 380, 16, 17)
$Label7 = GUICtrlCreateLabel("39", 469, 380, 16, 17)
$Label8 = GUICtrlCreateLabel("40", 517, 380, 16, 17)
$Label6 = GUICtrlCreateLabel("38", 413, 380, 16, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Listset("spdm,GG1DM,GG2DM,SL")
#EndRegion ### END Koda GUI section ###
Local $guiitem[1]
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $GUI_Button
tianjiaxinxi()
;GUICtrlDelete($ListView1)
Listset("spdm,GG1DM,GG2DM,SL")
cls()
;~ del()
;~ MsgBox(1,"1",GUICtrlRead($ListView1[1]))
_GUICtrlListView_SetItemSelected($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1,True,True)
Case $GUI_Input2
GUICtrlSetStyle($GUI_Input36, $ES_READONLY+$ES_AUTOHSCROLL+$ES_AUTOVSCROLL)
;MsgBox(1,"1",_GUICtrlListView_GetItemCount($ListView1))
;~ Case $a[1] To $a[$a[0]]
;~ $s = 0
;~ $log = _GUICtrlListView_GetItemCount($ListView1)
;~ For $i = 0 To $log
;~ If _GUICtrlListView_GetItemChecked($ListView1, $i) = True Then
;~ $s += 1
;~ EndIf
;~ Next
;~ If $s = 1 Then
;~ MsgBox (1,"单项",$s)
;~ Else
;~ MsgBox(1,"选择2项以上",$s)
;~ EndIf
EndSwitch
WEnd
;~ Local $b,$s,$aRow,$d
;~ Local $s_dbname = @ScriptDir ;数据库不需要开放接口,以免影响服务器安全;
;~ Local $o_Con, $o_Rs, $s_Tablename = "shangpin", $formatT = "text(255)" ;实际内存大小,数据表参数及数据表名,TEXT格式;
;~ ;Func databas()
#comments-start
$o_Con2 = ""
$s_dbname2 = "D:\我的文档\Downloads\UPDATE\Ms.mdb";
_AccessConnectConn($s_dbname2, $o_Con2, 0, "", "")
$arry1 = _RecordSearch($s_dbname2, "select * from shangpin where spdm = '" & GUICtrlRead ($GUI_Input1) & "'", $o_Con2)
$d = UBound ($arry1)
;MsgBox(1,"ss", $a)
If $d > 1 Then
$ros = _GUICtrlListView_GetItemCount($GUI_ListBox)
_GUICtrlListView_AddItem($GUI_ListBox,$ros+1,0)
_GUICtrlListView_AddSubItem($GUI_ListBox,$ros,GUICtrlRead ($GUI_Input1) ,1)
_GUICtrlListView_AddSubItem($GUI_ListBox,$ros,GUICtrlRead ($GUI_Input2),2)
$aRow=_GUICtrlListView_GetItemText($GUI_ListBox, 1)
MsgBox(1,"ss", $aRow)
Else
MsgBox(1,"ss", $d)
EndIf
$output = ""
For $r = 0 to UBound($aRow,1) - 1
$output = $output & @LF
For $c = 0 to UBound($aRow,2) - 1
$output = $output & $aRow[$r][$c] & " "
Next
Next
MsgBox(4096,"数组内容", $output)
;_GUICtrlListView_AddSubItem($GUI_ListBox,0,GUICtrlRead ($GUI_Input36),5,1)
;_GUICtrlListView_AddSubItem($GUI_ListBox,0,GUICtrlRead ($GUI_Input37),6,1)
;_GUICtrlListView_AddSubItem($GUI_ListBox,0,GUICtrlRead ($GUI_Input38),7,1)
;_GUICtrlListView_AddSubItem($GUI_ListBox,0,GUICtrlRead ($GUI_Input39),8,1)
;_GUICtrlListView_AddSubItem($GUI_ListBox,0,GUICtrlRead ($GUI_Input40),9,1)
;_GUICtrlListView_AddColumn($GUI_ListBox, "姓名", 80, 1)
;Else
;MsgBox(1,"ss", $a)
;EndIf
;_GUICtrlListView_AddSubItem($GUI_ListBox, 0, "34", 2, 2)
#comments-end
;EndFunc ;==>databas
Func Listset($Tiaojian);;;;;;;;;;;;;列表字段的读取与创建......$tiaojiao变量不能为*
GUISetState(@SW_SHOW, $Form1_1)
$clt = "商品代码|颜色|尺码|数量";;;;;;;;;;;;;;
$addfld = ObjCreate("ADODB.Connection");连接数据库
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$RS.Open("Select " & $Tiaojian & " From " & $tblname & " " & $swhere & " " & $zdywhere);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$zdsl = $RS.fields.count ;;;;统计字段数目
; If $checkbutt1 = 1 Then;;;;;检查是不按BUTTON的按钮而触发
; For $iii = 0 To $zdsl - 1
;$clt = $clt & String($RS.Fields($iii).name & "|");合并字段
; Next
;GUICtrlDelete($GUI_ListBox)
$ListView1 = GUICtrlCreateListView($clt, 6, 2, 672, 365)
;~ _GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_CHECKBOXES))
GUICtrlSendMsg($ListView1, $LVM_SETEXTENDEDLISTVIEWSTYLE, $LVS_EX_GRIDLINES, $LVS_EX_GRIDLINES)
For $i8 = 0 To $zdsl - 1
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), $i8, 2)
Next
$xsItemset = "";;;;;;;;;;;;;;;;;;
$zdsl = $RS.fields.count ;;;;统计字段数目
While Not $RS.eof And Not $RS.bof;;;;;写入item
If @error = 1 Then ExitLoop
$xsItemset = "";;;;;;;;;;
For $iiii = 0 To $zdsl - 1
$xsItemset = $xsItemset & $RS.Fields($iiii).value & "|";;写入对应的list列数
;~ $a = GUICtrlRead($ListView1)
;~ _GUICtrlListView_SetItemSelected($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1)
Next
$guiitem = GUICtrlCreateListViewItem($xsItemset, $ListView1)
;~ $a = GUICtrlRead($guiitem)
;~ MsgBox(1,"item",$guiitem)
;_GUICtrlListView_SetItemSelected($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1)
;If $RS.Fields("缴费情况" ).value = "未缴费" Then GUICtrlSetColor($guiitem, 0xff0000)
;~ $qqqq = GUICtrlRead($guiitem)
$RS.movenext
WEnd
;~ _GUICtrlListView_SetItemSelected($ListView1, _GUICtrlListView_GetItemCount($ListView1) - 1,True,True)
_GUICtrlListView_ClickItem($ListView1,_GUICtrlListView_GetItemCount($ListView1)-1)
;~ $checkbutt1 = 0
$RS.close
$addfld.Close
; Else;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;用来修改功能用的
; MsgBox(1,"aa","aa")
; EndIf
EndFunc
Func tianjiaxinxi()
$smdm = GUICtrlRead($GUI_Input1)
$ys =GUICtrlRead($GUI_Input2)
$cm34 = GUICtrlRead($GUI_Input34)
$cm35 = GUICtrlRead($GUI_Input35)
$cm36 = GUICtrlRead($GUI_Input36)
$cm37 = GUICtrlRead($GUI_Input37)
$cm38 = GUICtrlRead($GUI_Input38)
$cm39 = GUICtrlRead($GUI_Input39)
$cm40 = GUICtrlRead($GUI_Input40)
$sqlstr = "insert into SHOPBILLMX (SPDM,GG1dm) values ('aa','bb')"
$tblname = "SHOPBILLMX"
$tj = "spdm"
$bm = "shangpin"
$yb = "SPGG1"
$Y2 = "ggdm"
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$RS = ObjCreate("ADODB.Recordset")
$RS.ActiveConnection = $addfld
$y3 = ObjCreate("ADODB.Recordset")
$y3.ActiveConnection = $addfld
;$RS.Open("Select " & $tj & " From " & $bm & " " & $swhere & "" & $smdm)
;$RS.Open("Select " & $tj & " From " & $bm & " " & $swhere & $smdm)
;$RS.Open("Select " & $tj & " From " "where" "spdm=" & $smdm)
;$rs.open("select spdm from where shopbillmx where spdm = 00880002")
If $smdm <> "" And $ys <> "" Then
$RS.Open("Select " & $tj & " From " & $bm & " " & "where spdm =" & "'"&$smdm&"'")
$a = 0
$y = 0
$a = $RS.Fields($a).value
$y3.Open("Select " & $Y2 & " From " & $yb & " " & "where spdm =" & "'"&$smdm&"'" & "and " & "ggdm =" & "'" &$ys& "'")
$Y = $y3.Fields($y).value
MsgBox(1,"YS",$Y)
IF StringRegExp($a,$smdm) And StringRegExp($Y,$ys) Then
If $cm34 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "34," & $cm34 & ")")
If $cm35 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "35," & $cm35 & ")")
If $cm36 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "36," & $cm36 & ")")
If $cm37 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "37," & $cm37 & ")")
If $cm38 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "38," & $cm38 & ")")
If $cm39 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "39," & $cm39 & ")")
If $cm40 <> "" Then $addfld.Execute("insert into SHOPBILLMX (DJBH,SPDM,GG1DM,GG2DM,SL) values (" & "'" & $bm & "'" & "," & "'" & $smdm & "'" & "," & $ys & "," & "40," & $cm40 & ")")
Else
cls()
EndIf
;$addfld.Execute("insert into " & $tblname & " (spdm,gg1dm,gg2dm,sl) values ('00880002',99,40,12)")
;$addfld.Execute("insert into " & $tblname & " (用户名,房号) values (" & $addusermane & "," & $addfanhao & ")")
;$addfld.Execute("insert into " & $tblname & " ([djbh],[spdm],[GG1DM],[GG2DM],[sl]) values (" & "PDF011012150001" & "," & $smdm & "," & $ys & ","&"34"&","&$cm34&")")
Else
MsgBox(0, "错误", "商品代码或尺码不能为空")
cls()
EndIf
EndFunc ;==>tianjiaxinxi
Func del()
$tblname = "SHOPBILLMX"
$Strn = GUICtrlRead(GUICtrlRead($ListView1))
$Strnspin = StringSplit($Strn, "|")
$Strnspinshux = $Strnspin[0]
MsgBox(1,"strnspinshux",$Strnspinshux)
$addfld = ObjCreate("ADODB.Connection")
$addfld.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & $mdb_data_path & ";Jet Oledb:Database Password=" & $mdb_data_pwd)
$sQuery = "DELETE FROM " & $tblname & " IN '" & $mdb_data_path & "' WHERE AutoID" & " = " & $Strnspin[$Strnspinshux]
$addfld.execute($sQuery)
$addfld.close
MsgBox(4096, "提示- ", "房号:" & $Strnspin[1] & " 删除成功!!!")
EndFunc ;==>del
Func cls()
GUICtrlSetData($GUI_Input1, "")
GUICtrlSetData($GUI_Input2, "")
GUICtrlSetData($GUI_Input34, "")
GUICtrlSetData($GUI_Input35, "")
GUICtrlSetData($GUI_Input36, "")
GUICtrlSetData($GUI_Input37, "")
GUICtrlSetData($GUI_Input38, "")
GUICtrlSetData($GUI_Input39, "")
GUICtrlSetData($GUI_Input40, "")
EndFunc
Func WM_NOTIFY($hWndGUI, $MsgID, $WParam, $LParam)
Local $tagNMHDR, $Event, $hWndFrom, $IDFrom
Local $tagNMHDR = DllStructCreate("int;int;int", $LParam)
If @error Then Return $GUI_RUNDEFMSG
$IDFrom = DllStructGetData($tagNMHDR, 2)
$Event = DllStructGetData($tagNMHDR, 3)
$tagNMHDR = 0
Switch $IDFrom;选择产生事件的控件
Case $ListView1
Switch $Event; 选择产生的事件
Case $NM_CLICK ; 左击
Case $NM_DBLCLK ; 双击
MsgBox(1,"2","22")
Case $NM_RCLICK ; 右击
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?加入
×
|