I want to enumerate all of the controls on a form containing my activex control and list them in the property page of my control.
ARRRGGGHHH!!! Can't quite figure it out.
TIA!
C
Printable View
I want to enumerate all of the controls on a form containing my activex control and list them in the property page of my control.
ARRRGGGHHH!!! Can't quite figure it out.
TIA!
C
If you want to do it from an activex. You have to pass the form and receive type will be form and then do the following.
me would be the form passed over.
VB Code:
Dim sControls As Control For Each sControls In Me.Controls List1.AddItem sControls.Name Next
Code is really Sloppy but here is the control
Control:
VB Code:
Public Function EnumControls(frm As Form) As String() Dim sControls As Control Dim iControlCount As Integer iControlCount = 0 Dim sArr() As String For Each sControls In frm.Controls ReDim Preserve sArr(iControlCount) sArr(iControlCount) = sControls.Name iControlCount = iControlCount + 1 Next EnumControls = sArr End Function
Form:
VB Code:
Private Sub Form_Load() Dim sControlArr() As String sControlArr = UserControl11.EnumControls(Me) For i = 0 To UBound(sControlArr) List1.AddItem sControlArr(i) Next End Sub
Is there anyway the activex control can get the controls names without the form helping (or user)?
C
I do not get when you say the names are you talking about what you are naming them. That is the names of them. If you wan to find out what type they are you have to create a case select and use the TypeOf keyword.