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.
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 flow_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.PictureAlignment = lvwtile
Listview1.picture = picgreenbar.image
End Sub
There are not many volumes, but it is very practical.