i have a code that colors a row in the listview
when i run it for the first time then i see the colored listview and everything is ok
when i open the listview again or refresh then i get error there is already a control with the name "picAlt"
cant figure why
this is the code:
tnx in advanced
when i run it for the first time then i see the colored listview and everything is ok
when i open the listview again or refresh then i get error there is already a control with the name "picAlt"
cant figure why
this is the code:
Code:
Private Sub AltLVBackground(LsVw As ListView, _
ByVal BackColorOne As OLE_COLOR, _
ByVal BackColorTwo As OLE_COLOR)
Dim lh As Long
Dim lSM As Byte
Dim picAlt As PictureBox
With LsVw
If .View = lvwReport And .ListItems.Count Then
Set picAlt = Me.Controls.Add("VB.PictureBox", "picAlt") here is the error
lSM = .Parent.ScaleMode
.Parent.ScaleMode = vbTwips
.PictureAlignment = lvwTile
lh = .ListItems(1).Height
With picAlt
.BackColor = BackColorOne
.AutoRedraw = True
.Height = lh * 2
.BorderStyle = 0
.Width = 10 * screen.TwipsPerPixelX
picAlt.Line (0, lh)-(.ScaleWidth, lh * 2), BackColorTwo, BF
Set LsVw.Picture = .Image
End With
Set picAlt = Nothing
LsVw.Parent.ScaleMode = lSM
End If
End With
Unload Me
End Sub
Code:
Private Sub Form_Activate()
AltLVBackground LsVw, vbWhite, &HC0FFFF
End Sub