Get Classes in a project at design time

  • Thread starter Thread starter Jan Tielens
  • Start date Start date
J

Jan Tielens

Hi all

I want to make a usercontrol that has a property that
lists all the Classes of the project of the form where the
usercontrol is placed on.

I know how to create a custom StringConvertor and how to
overload the GetStandardValues function, to display a
dropdown list. But I'm need to now how I can retrieve the
classes at design time of the project. Any thoughts?

Thx
Jan
 
Don't use StringConverter -- that's only for PropertyGrid support.

To get a list of all types in an assembly, use Assembly.GetTypes().
From there, listing their names is easy.
 
I know to use an assembly to get the types. But how do I
get to the assembly of the project at DESIGN TIME?

Jan
 
I alread discovered it:
Public Overloads Overrides Function GetStandardValues
(ByVal context As
System.ComponentModel.ITypeDescriptorContext) As
System.ComponentModel.TypeConverter.StandardValuesCollectio
n
Dim typeName As String = CType(CType
(context.Container, IDesignerHost).RootComponent,
Object).GetType.FullName

Dim ass As Reflection.Assembly =
Reflection.Assembly.GetAssembly(CType(context.Container,
IDesignerHost).GetType("WindowsApplication26.Form1"))

Dim al As New ArrayList
For Each t As Type In ass.GetTypes
al.Add(t.FullName)
Next

Dim s As New
System.ComponentModel.TypeConverter.StandardValuesCollectio
n(al)
Return s
End Function
 
Back
Top