Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get a list of a controls properties programmatically.?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Does anyone know if there's a way to programmatically get a list of properties for a specific control?

something to the effect of:

Code:
For i = 0 to cmdCommand.Properties.Count - 1
     List1.AddItem cmdCommand.Properties(i).Name
Next i

Thanks!

--NipsMG
 
Hi!

This should work:

Dim prp As Property

For Each prp In cmdCommand.Properties
List1.AddItem prp.Name
Next prp

hth
Jeff Bridgham
 
uhmm.. ok am I missing something?

I don't have property defined as a type

"User defined type not defined"

--NipsMG
 
1. Start a new Standard.Exe project.
2. Add a Reference (VB Menu -> Project -> References) to "TypeLib Information"
3. Add a Listbox (List1) to Form1.
4. Copy/Paste the following into the Form1 code window.
5. Press F5 to run. All of the properties for List1 will be displayed in the Listbox.

<----- Code Begin ----->

Option Explicit

Private Sub Form_Load()

With Screen
Me.Move 0.25 * .Width, 0.25 * .Height, 0.5 * .Width, 0.5 * .Height
End With

Call xPropertyList(List1, List1)

End Sub

Private Sub Form_Resize()

With Me
If .WindowState = vbMinimized Then Exit Sub
List1.Move 0, 0, .ScaleWidth, .ScaleHeight
End With

End Sub

Public Sub xPropertyList(ByRef lstOutput As ListBox, ByRef QueriedObject As Object)

Dim TLInfo As TLI.InterfaceInfo
Dim SR As TLI.SearchResults
Dim SI As SearchItem
Dim lngReturn As Long
On Error GoTo ErrorHandler

' grab info from object
Set TLInfo = TLI.InterfaceInfoFromObject(QueriedObject)
Set SR = TLInfo.Members.GetFilteredMembers(False)

' Loop through attribute members of the object
For Each SI In SR
lngReturn = SI.InvokeKinds
' check if it is a property
' If you want to use this to check for a
' function or sub, also check if lngReturn = 1
Select Case lngReturn
Case 2, 6, 10, 12, 14
lstOutput.AddItem SI.Name
End Select
Next SI

ErrorHandler:

Set TLInfo = Nothing

End Sub

<----- Code End ----->


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top