Link to home
Start Free TrialLog in
Avatar of TheUndecider
TheUndeciderFlag for United States of America

asked on

Check Whether A Panel Has No Controls Inside (Is Empty)

Hello,


I'm working in a VB.NET Windows project that contains a panel. The user adds records to this panel by selecting an item from a combo box outside this panel. The records get added to the panel in textboxes.  When the user is done, they submit the record(s) in the panel to the database by hitting a button below the panel.  

I want to check whether the user has added any records in the panel before submitting them to the database.  I'm hoping to have something in the button that checks whether the panel is empty ( it has no records  = no textboxes) before submitting.  

Does anyone know how to check whether a panel has no controls in it?

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There's also a HasChildren() property:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.haschildren.aspx

So:

    If Panel1.HasChildren() Then

    End If