国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > 綜合 > 正文

用代碼實現ListView控件的行間隔顏色!

2024-07-21 02:24:39
字體:
來源:轉載
供稿:網友

listview控件在寫程序的時候經常會用到,是一個很實用的控件。不過在顯示的數據比較多的時候(以報表風格顯示數據,類似于資源管理器的詳細查看),看起來不方便。大家可能對論壇比較熟悉,大多數論壇顯示的時候都是每行以不同的顏色進行顯示,以區分出不同行的數據。其實我們也可以借鑒一下這個方法,用程序來實現listview控件的行間隔顏色。



                        崔占民

                    email:[email protected]



  首先在窗口中添加一個listview控件,方法:菜單->工程->部件->microsoft window common control 6.0 (后面為版本號)。再添加一個picture控件,改名為picgreenbar。

  實現的代碼如下:

option explicit

private sub form_load()
dim i as integer
dim ifontheight as long
dim ibarheight as integer
dim j as integer
dim itmx as listitem
dim colhead as columnheader
listview1.columnheaders.add , , "this is just a simple example"
listview1.columnheaders(1).width = 3000

'添加一些實驗數據
for j = 1 to 33
set itmx = listview1.listitems.add()
itmx.text = "this is item number " & cstr(j)
next j

me.scalemode = vbtwips
picgreenbar.scalemode = vbtwips
picgreenbar.borderstyle = vbbsnone
picgreenbar.autoredraw = true
picgreenbar.visible = false
picgreenbar.font = listview1.font
ifontheight = picgreenbar.textheight("b") + screen.twipsperpixely
ibarheight = (ifontheight * 1)
picgreenbar.width = listview1.width
'======
picgreenbar.height = ibarheight * 2
picgreenbar.scalemode = vbuser
picgreenbar.scaleheight = 2
picgreenbar.scalewidth = 1
'draw the actual bars
picgreenbar.line (0, 0)-(1, 1), vbwhite, bf
picgreenbar.line (0, 1)-(1, 2), rgb(227, 241, 226), bf
'======
listview1.picturealignment = lvwtile
listview1.picture = picgreenbar.image
end sub


  代碼量不多,不過很實用。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 自治县| 巴里| 昂仁县| 漯河市| 平顺县| 宿州市| 冕宁县| 陆川县| 奉节县| 威远县| 黎平县| 镇江市| 思茅市| 永清县| 遵义县| 鲜城| 海伦市| 拉孜县| 湄潭县| 杂多县| 台江县| 海盐县| 霍邱县| 顺昌县| 轮台县| 石河子市| 根河市| 大理市| 万山特区| 临夏市| 建平县| 乐平市| 云和县| 大庆市| 齐齐哈尔市| 三原县| 朝阳区| 崇义县| 罗山县| 石嘴山市| 郴州市|