Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21090

color listview gets error after refreshing

$
0
0
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:
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

tnx in advanced

Viewing all articles
Browse latest Browse all 21090

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>