改变没有数据的ListView的行的背景色或文本色[已解决]
本帖最后由 lllangxx 于 2010-7-17 12:37 编辑想要让图中 没有数据的ListView的行的背景色或文本色 改变该怎样写 ?
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GUIListBox.au3>
#include <DateTimeConstants.au3>
#include <GuiListView.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", 1)
Opt("GUICloseOnESC", 0)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Button1 = GUICtrlCreateButton("test", 472, 400, 121, 25, $WS_GROUP) ;write
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("read", 20, 400, 121, 25, $WS_GROUP);read
GUICtrlSetOnEvent(-1, "Button2Click")
$ListView1 = GUICtrlCreateListView("", 16, 8, 601, 385) ;Listview
_GUICtrlListView_SetExtendedListViewStyle($ListView1 ,BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ;ListView样式
_GUICtrlListView_AddColumn($ListView1, "test", 50, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 60, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 120, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 180, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 240, 0)
;-------------------------------------
_GUICtrlListView_AddItem($ListView1, "test",0)
_GUICtrlListView_AddSubItem($ListView1, 0, "test1", 1, 1)
_GUICtrlListView_AddSubItem($ListView1, 0, "test2", 2, 2)
;--------------------------
GUICtrlSetOnEvent(-1, "ListView1Click")
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 9)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $hquery, $aRow, $sqlit_ok, $ListView1,$date,$dates1,$dates2,$da
$date1 = GUICtrlCreateDate("", 200, 400, 100, 20,$DTS_SHORTDATEFORMAT);日历
Global $Input1
$Input1 = GUICtrlCreateInput("test", 350, 400, 100, 20)
$title = "SQLIT测式"
$Sqlit_path = "test.db"
_SQLite_Startup() ;加载Sqlit.dll
if Not FileExists($Sqlit_path) Then
SQLCreate()
EndIf
While 1
Sleep(100)
WEnd
Func SQLCreate()
_SQLite_Open($Sqlit_path)
_SQLite_Exec(-1,"Create Table If NOT Exists Audit(id integer primary key autoincrement,dates Text,datess Test,datesss Test);")
_SQLite_Close()
EndFunc
Func SQLwrite()
Local $input = GUICtrlRead($Input1)
$date=GUICtrlRead($date1)
$dates1 = $date
$dates2 = $date
_SQLite_Open($Sqlit_path)
_SQLite_Exec(-1,"insert into Audit (dates,datess,datesss) values ('"& $date &"','"& $dates1 &"','"& $Input &"');")
;MsgBox(4096, "write", "insert into Audit (dates,datess,datesss) values ('"& $date &"','"& $dates1 &"','"& $dates2 &"');", 5)
_SQLite_Close()
$input=0
EndFunc
Func SQLread()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
_SQLite_Open($Sqlit_path)
_SQLite_Query(-1,"SELECT * FROM AuditORDER BY id ASC;", $hquery)
While _SQLite_FetchData($hquery, $aRow) = $SQLITE_OK
GUICtrlCreateListViewItem ( $aRow&"|"& $aRow&"|"& $aRow& "|"& $aRow,$ListView1)
WEnd
_SQLite_Close()
EndFunc
Func Button1Click()
SQLwrite()
SQLread()
;MsgBox(4096, "Button1Click", "write", 2)
EndFunc
Func Button2Click()
SQLread()
EndFunc
Func Form1Close()
exit
EndFunc
Func Form1Restore()
EndFunc
Func ListView1Click()
EndFunc 已解决{:face (316):}
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <Date.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <GUIListBox.au3>
#include <GuiListView.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <DateTimeConstants.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Opt("TrayIconHide", 1)
Opt("GUICloseOnESC", 0)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 633, 454, 192, 114)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Button1 = GUICtrlCreateButton("test", 472, 400, 121, 25, $WS_GROUP) ;write
GUICtrlSetOnEvent(-1, "Button1Click")
$Button2 = GUICtrlCreateButton("read", 20, 400, 121, 25, $WS_GROUP);read
GUICtrlSetOnEvent(-1, "Button2Click")
$ListView1 = GUICtrlCreateListView("", 16, 8, 601, 385) ;Listview
_GUICtrlListView_SetExtendedListViewStyle($ListView1 ,BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES)) ;ListView样式
_GUICtrlListView_AddColumn($ListView1, "test", 50, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 60, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 120, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 180, 0)
_GUICtrlListView_AddColumn($ListView1, "test", 240, 0)
;-------------------------------------
_GUICtrlListView_AddItem($ListView1, "test",0)
_GUICtrlListView_AddSubItem($ListView1, 0, "test1", 1, 1)
_GUICtrlListView_AddSubItem($ListView1, 0, "test2", 2, 2)
;--------------------------
GUICtrlSetOnEvent(-1, "ListView1Click")
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetMinHeight($StatusBar1, 9)
GUISetState(@SW_SHOW)
Global $hquery, $aRow, $sqlit_ok, $ListView1,$date,$dates1,$dates2,$da
$date1 = GUICtrlCreateDate("", 200, 400, 100, 20,$DTS_SHORTDATEFORMAT);日历
Global $Input1
$Input1 = GUICtrlCreateInput("test", 350, 400, 100, 20)
#EndRegion ### END Koda GUI section ###
$title = "SQLIT测式"
$Sqlit_path = "test.db"
_SQLite_Startup() ;加载Sqlit.dll
if Not FileExists($Sqlit_path) Then
SQLCreate()
EndIf
While 1
Sleep(100)
WEnd
Func SQLCreate()
_SQLite_Open($Sqlit_path)
_SQLite_Exec(-1,"Create Table If NOT Exists Audit(id integer primary key autoincrement,dates Text,datess Test,datesss Test);")
_SQLite_Close()
EndFunc
Func SQLwrite()
Local $input = GUICtrlRead($Input1)
$date=GUICtrlRead($date1)
$dates1 = $date
$dates2 = $date
_SQLite_Open($Sqlit_path)
_SQLite_Exec(-1,"insert into Audit (dates,datess,datesss) values ('"& $date &"','"& $dates1 &"','"& $Input &"');")
;MsgBox(4096, "write", "insert into Audit (dates,datess,datesss) values ('"& $date &"','"& $dates1 &"','"& $dates2 &"');", 5)
_SQLite_Close()
$input=0
EndFunc
Func SQLread()
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($ListView1))
_SQLite_Open($Sqlit_path)
_SQLite_Query(-1,"SELECT * FROM AuditORDER BY id ASC;", $hquery)
While _SQLite_FetchData($hquery, $aRow) = $SQLITE_OK
if $aRow=="" Then
; MsgBox(0,$aRow,$aRow)
GUICtrlCreateListViewItem ( $aRow&"|"& $aRow&"|"& $aRow& "|"& $aRow,$ListView1)
$a = ControlListView($Form1, "", $ListView1, "FindItem", $aRow)
GUICtrlSetColor(_GUICtrlListView_GetItemParam($ListView1, $a), '0xFF0000') ;红
Else
GUICtrlCreateListViewItem ( $aRow&"|"& $aRow&"|"& $aRow& "|"& $aRow,$ListView1)
EndIf
WEnd
_SQLite_Close()
EndFunc
Func Button1Click()
SQLwrite()
SQLread()
;MsgBox(4096, "Button1Click", "write", 2)
EndFunc
Func Button2Click()
SQLread()
EndFunc
Func Form1Close()
exit
EndFunc
Func Form1Restore()
EndFunc
Func ListView1Click()
EndFunc
能自己解决问题,还能将解决问题的代码补上让后人参考
Good! thankyouverymuch 学习了,谢谢楼主的无私 留名 需要·~~
页:
[1]