Add Controls

Carlos++

Active member
Joined
Sep 14, 2007
Messages
26
Location
As. Paraguay
Programming Experience
5-10
is there a way to add controls in runtime using the toolbar that provides vs2005 and the properties options?

clearly: I want to add controls with automatic code generation, as vs2005 does.

:)
 
You will need to use the PropertyGrid control.

Here's an idea to list the Forms controls using reflection, non-public and abstract classes are filtered out. You probably have to make some adjustments.
VB.NET:
Sub listControls()
    For Each t As Type In GetType(Form).Assembly.GetTypes
        If t.IsPublic AndAlso Not t.IsAbstract Then
            If t.IsSubclassOf(GetType(Control)) Then
                ListBox1.Items.Add(t.Name)
            End If
        End If
    Next
End Sub
If you want to include components, check if IsSubclassOf Component instead of Control.

When adding controls at runtime no code is generated, only objects are created in memory, they are gone next time you start unless you save information and use this to recreate them next runtime.
 
Back
Top