[RESOLVED] Run-time control and control array
No idea how to describe this problem, but just add this to a form :
VB Code:
Option Explicit
Dim WithEvents Lst As ListBox
Private Sub Form_Load()
Set Lst = List1(0)
End Sub
List1() is a control array created at design time. Error occurs :
Quote:
459 - Object or class does not support the set of events
Anyway to avoid it?
Re: Run-time control and control array
You cannot use WithEvents on a control that is part of a control array.
Re: Run-time control and control array
Simple enough I guess... Oh well :( Thanks :)
Re: [RESOLVED] Run-time control and control array
Control array elements have their events "hacked" to include an Index property so you know which control fired the event. That hacking can't be (or isn't anyway) done for an object reference. For the same reason, you can't use WithEvents with arrays of object references.
Re: [RESOLVED] Run-time control and control array
I got around this loading items and adding them to the collection of the form with "_1" or another number at the end and then referencing them through the form's controls collection again :) Works just fine :D