biwfmm 发表于 2012-4-22 17:17:26

如何更改用数组显示的listview某一行颜色

本帖最后由 biwfmm 于 2012-4-22 17:40 编辑

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <Array.au3>

$hGui = GuiCreate('更改指定ListView的字体颜色', 400, 300)

Local $lvsExStyle = BitOr($lvs_ex_fullrowselect, _
                        $lvs_ex_gridlines, _
                        $lvs_ex_doublebuffer)
Local $lvs1 = GuiCtrlCreateListView("List1||", 5, 5, 390, 260, $lvs_report, $lvsExStyle)
$Button1 = GUICtrlCreateButton("更改颜色", 104, 270, 75, 25)
$Input1 = GUICtrlCreateInput("0xFF0000", 192, 272, 121, 21)
Local $var
For $d = 0 to 9
        $var[$d] = $d
Next
_GUICtrlListView_AddArray( $lvs1,$var)
GUISetState()

While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                Case $Button1
                        _GuiListView_SetItemColor($lvs1,GUICtrlRead($Input1))
      EndSwitch
WEnd

;~ 改变指定 ListView 项目的字体颜色               
Func _GuiListView_SetItemColor($hWnd, $Color)
      $iItem = _GUICtrlListView_GetItemParam($hWnd,_GUICtrlListView_GetSelectionMark($hWnd))
      Return GUICtrlSetColor($iItem, $Color)
EndFunc


不用消息的。。比较简单。。

user3000 发表于 2012-4-22 17:59:36

回复 1# biwfmm

发帖前最好在论坛搜索一下!
对您来说可能省下学习时间, 对论坛来说减少了不必要的资源开销!

设置 listview 某行数据的颜色?
http://www.autoitx.com/forum.php?mod=viewthread&tid=30079&highlight=listview

关于listview改变整列的底色
http://www.autoitx.com/forum.php?mod=viewthread&tid=17078&highlight=listview

lpxx 发表于 2012-4-22 18:58:17

这个论坛早就讨论过的,有实例的。

netegg 发表于 2012-4-22 20:39:38

日,又是个懒到怕自己动手会over的主

xms77 发表于 2012-4-22 21:20:54

回复 4# netegg
呵呵,蛋哥有点蛋疼了,要淡定!
页: [1]
查看完整版本: 如何更改用数组显示的listview某一行颜色