| < Free Open Study > |
|
Components on a form are referenced through the use if IComponent objects, along with PropertyDescriptor and PropertyDescriptorCollection objects. Assuming that the user has selected one or more components on a form, the following code lists the Name property of each component:
' loop through the selected component collection ' listing properties Dim pd As PropertyDescriptor Dim pdc As PropertyDescriptorCollection Dim ic As IComponent Dim c As Component For Each c In sel.GetSelectedComponents ic = CType(c, IComponent) pdc = TypeDescriptor.GetProperties(ic) pd = pdc("Text") s = pd.GetValue(ic).ToString pd = pdc("Name") s2 = pd.GetValue(ic).ToString MsgBox("Component Text = " & s & Chr(10) & _ "Component Name = " & s2) Next
| < Free Open Study > |
|