Hello,
When i add custom controls to my Frame1 it takes forever and it slow when i scroll it
any idea how to solve it?
Private Sub CreateFinished(Top As Integer, id As Integer, artnumber As String, titel As String,Price as double, myid As Integer)
Dim pathToPicture As String
pathToPicture = ThisWorkbook.Path & "\emp1.bmp"
Dim idString As String
Dim ccont1000 As MSForms.Frame
Set ccont1000 = Frame1.Controls.Add("Forms.Frame.1")
idString = myid
With ccont1000
.Width = Frame1.Width - 18
.Height = 60
.Top = Top - 0.1
.Left = 2
.BorderStyle = fmBorderStyleNone
.SpecialEffect = fmSpecialEffectFlat
.Name = idString '"Control" & id
.BackColor = RGB(47, 59, 71)
.MousePointer = fmMousePointerCustom
End With
'=CheckBox
Dim cCont0 As MSForms.CheckBox
Set cCont0 = ccont1000.Controls.Add _
("Forms.CheckBox.1")
With cCont0
.Name = "CheckBox"
.Left = 10
.Top = 18
.BackColor = RGB(255, 255, 255)
.BackStyle = fmBackStyleTransparent
.ForeColor = RGB(255, 255, 255)
.Tag = idString
.Locked = True
.MousePointer = fmMousePointerCustom
End With
'=Artnumber
Dim cCont1 As MSForms.Label
Set cCont1 = ccont1000.Controls.Add _
("Forms.Label.1")
With cCont1
.Name = idString
.Width = 72
.Height = 39
.Left = 34
.Top = 10
.Caption = vbCrLf & artnumber
.TextAlign = fmTextAlignCenter
.BorderStyle = fmBorderStyleNone
.BackColor = RGB(255, 255, 255)
.BackStyle = fmBackStyleTransparent
.ForeColor = RGB(255, 255, 255)
.Tag = idString
.MousePointer = fmMousePointerCustom
End With
'=photo
Dim fileName As String
Dim cCont2 As MSForms.Image
Set cCont2 = ccont1000.Controls.Add _
("Forms.Image.1")
With cCont2
fileName = pathToPicture
Application.DisplayAlerts = False
.Picture = LoadPicture(fileName)
.Name = idString
.Tag = fileName
.Width = 48
.Height = 48
.Left = 125
.Top = 7
.MousePointer = fmMousePointerCustom
.PictureSizeMode = fmPictureSizeModeStretch
End With
Dim cCont100 As MSForms.Image
Set cCont100 = ccont1000.Controls.Add _
("Forms.Image.1")
With cCont100
.Name = idString
.Tag = fileName
.Picture = circuitButtonsForm.Label540.Picture
.PictureSizeMode = fmPictureSizeModeStretch
.BackStyle = fmBackStyleTransparent
.Width = 48
.Height = 52
.Left = 125
.Top = 7
.ControlTipText = titel
.MousePointer = fmMousePointerCustom
End With
'=Price
Dim cCont4 As MSForms.Label
Set cCont4 = ccont1000.Controls.Add _
("Forms.Label.1")
With cCont4
.Name = idString
.Width = 60
.Height = 39
.Left = 185
.Top = 10
.Caption = vbCrLf & FormatCurrency(price, 2)
.TextAlign = fmTextAlignCenter
.BorderStyle = fmBorderStyleNone
.BackColor = RGB(255, 255, 255)
.BackStyle = fmBackStyleTransparent
.ForeColor = RGB(255, 255, 255)
.Tag = idString
.MousePointer = fmMousePointerCustom
End With
End Sub
Frame1.ScrollTop = 0
For index = 0 To ListBoxHistory.ListCount - 1
Call CreateFinished(4 + (65 * index), index + 1, ListBoxHistory.List(index, 1), ListBoxHistory.List(index, 8), Format(ListBoxHistory.List(index, 2)), ListBoxHistory.List(index, 0))
Next index
Thank you.