Create a Windows Application Project from an Add-in

 < Free Open Study > 

Reference All of the Selected Controls on a Form

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 > 

Writing Add-Ins for Visual Studio  .NET
Writing Add-Ins for Visual Studio .NET
ISBN: 1590590260
EAN: 2147483647
Year: 2002
Pages: 172
Authors: Les Smith © 2008-2017.
If you may any questions please contact us: