Hi Tom,
It is not so easy or evident. Technically, for a control to accept other
controls inside it at design-time (selectable controls, using drag and drop,
etc. like a GroupBox), its designer must be the
System.Windows.Forms.Design.ParentControlDesigner class, or a derived one.
I am not sure if you know about the design-time architecture, designers,
attributes and so on, so I have written the whole function that I think that
you are looking for:
' Add the System.Design.dll assembly to your project's references !!!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim ctlGroupBox As New GroupBox()
Dim ctlTabControl As New TabControl()
Dim ctlTextBox As New TextBox()
IsContainerControl(ctlGroupBox)
IsContainerControl(ctlTabControl)
IsContainerControl(ctlTextBox)
End Sub
Public Function IsContainerControl(ByVal ctlControl As Control) As Boolean
Dim bResult As Boolean = False
Dim objControlType As Type
Dim objDesignerType As Type
Dim objAttribute As Attribute
Dim objDesignerAttribute As System.ComponentModel.DesignerAttribute
objControlType = ctlControl.GetType
For Each objAttribute In
objControlType.GetCustomAttributes(GetType(System.ComponentModel.DesignerAttribute),
False)
If TypeOf objAttribute Is System.ComponentModel.DesignerAttribute Then
objDesignerAttribute = CType(objAttribute,
System.ComponentModel.DesignerAttribute)
objDesignerType =
System.Type.GetType(objDesignerAttribute.DesignerTypeName)
If
GetType(System.Windows.Forms.Design.ParentControlDesigner).IsAssignableFrom(objDesignerType)
Then
bResult = True
Exit For
End If
End If
Next
MessageBox.Show(objControlType.FullName & " is a container control: " &
bResult.ToString)
Return bResult
End Function
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com