ListView controls are often used when writing programs, is a very practical control. However, when the data is displayed (in the report style display data, similar to the resource manager's detailed view), it is inconvenient. Everyone may be more familiar to the forum. Most forums are displayed by each line in different colors to distinguish between different lines of data. In fact, we can also learn from this method to implement the line interval color of the ListView control.
Program source code can be downloaded from your website: http://www.j2soft.cn/
Cui Moven
Email: cuizm@163.com
First add a listView control in the window. Method: Menu -> Enginee -> Parts -> Microsoft Window Common Control 6.0 (later is the version number). Add a Picture control, renamed Picgreenbar.
The code implemented is as follows:
Option expedition
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
'Add some experimental data 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.PictView1.Picture = PicgreenBar.Imagend Sub code is not much, But it is very practical.